Comments on: The Constraint kind https://jeltsch.wordpress.com/2013/02/14/the-constraint-kind/ Mathematics, computer science, and computers Thu, 17 Nov 2016 15:05:58 +0000 hourly 1 http://wordpress.com/ By: Wolfgang Jeltsch https://jeltsch.wordpress.com/2013/02/14/the-constraint-kind/#comment-575 Thu, 17 Nov 2016 15:05:58 +0000 http://jeltsch.wordpress.com/?p=567#comment-575 It means that contexts can be parameters of types and that they can also be instances of classes.

Parameters of types
You can define, for example, a type T of kind Constraint -> *. Then you can apply T to (Read a, Show a), for example, resulting in the type T (Read a, Show a) of kind *.
Instances of classes
Note that there is a common use of the term “instance” in the Haskell community that does not match the terminology used in the Haskell Report. Something like instance C T where […] is not an instance, and it also does not define an instance. Instead, it makes the type T and instance of the class C. Types are instances of classes. So when I said that contexts can be instances of classes, I meant that you can have, for example, an instance declaration instance C (Read a, Show a) where […], meaning that C must have kind Constraint -> Constraint.
]]>
By: ivan https://jeltsch.wordpress.com/2013/02/14/the-constraint-kind/#comment-574 Thu, 17 Nov 2016 08:58:11 +0000 http://jeltsch.wordpress.com/?p=567#comment-574 Nice. I grokked everything except the last 3 words of this sentence:

Classes, partially applied classes, and contexts can be parameters of types and instances of classes.

Does it mean that “contexts can be parameters of instances of classes”? Or does it mean that “contexts can be instances of classes”? Either way I’d appreciate some elaboration.

]]>
By: Constrained monads « Wolfgang Jeltsch https://jeltsch.wordpress.com/2013/02/14/the-constraint-kind/#comment-483 Thu, 03 Sep 2015 19:53:37 +0000 http://jeltsch.wordpress.com/?p=567#comment-483 […] my article The Constraint kind, I described a solution to this problem, which involved changing the Monad class. In this article, […]

]]>
By: Wolfgang Jeltsch https://jeltsch.wordpress.com/2013/02/14/the-constraint-kind/#comment-266 Sat, 09 Mar 2013 21:54:57 +0000 http://jeltsch.wordpress.com/?p=567#comment-266 It is nice to hear that you like my blog. Thank you for expressing your appreciation.

The Monad class given (but not invented) by me uses not only the ConstraintKinds, but also the TypeFamilies extension. ConstraintKinds is very new, and also TypeFamilies is not very old. So I suppose that this generalized Monad class will not make it into base very soon. We would have to ask the folks on the GHC or the library mailing list to know for sure.

That said, relying on extensions for base does not seem to be a problem as such, as base is already beyond standard Haskell. For example, Control.Monad.ST uses Rank2Types.

]]>
By: Luke Randall (@luke_randall) https://jeltsch.wordpress.com/2013/02/14/the-constraint-kind/#comment-265 Sat, 09 Mar 2013 21:31:32 +0000 http://jeltsch.wordpress.com/?p=567#comment-265 This is a really informative post; thank you for writing it. I don’t tend to comment much because my Haskell knowledge is at a level where I don’t have much to add to the dialogue, but I just wanted to express my appreciation for your blog, I’ve learnt a great deal from following it.

The example you give of generalizing the Monad type class is fantastic, as it seems to have no downsides, since any previously allowable instance can use the existing instance definition. Apart from the dependence on ConstraintKinds, is there any negative to this Monad definition? Is there any movement to thus generalize it? If not, why not? A reluctance to rely on an extension for a base library?

]]>
By: The Constraint kind | Theory Lunch https://jeltsch.wordpress.com/2013/02/14/the-constraint-kind/#comment-249 Thu, 14 Feb 2013 16:23:50 +0000 http://jeltsch.wordpress.com/?p=567#comment-249 […] I talked about the Constraint kind, a recent addition to Haskell. There is a write-up of my talk on my personal blog. […]

]]>