
Hi cafe! The ConstraintKinds extension makes it possible to create classes of classes, like this: class F c where cfmap :: c f => (a -> b) -> f a -> f b instance F Functor where cfmap = fmap instance F Monad where cfmap = liftM So, basically we are saying that "c" is a class that has some special properties. Is it possible to express the property "c is a subclass of a specific class d"? Like class F c where Functor f => c f

On Thu, Jun 7, 2012 at 1:42 PM, Miguel Mitrofanov
Hi cafe!
The ConstraintKinds extension makes it possible to create classes of classes, like this:
class F c where cfmap :: c f => (a -> b) -> f a -> f b instance F Functor where cfmap = fmap instance F Monad where cfmap = liftM
So, basically we are saying that "c" is a class that has some special properties.
Is it possible to express the property "c is a subclass of a specific class d"? Like class F c where Functor f => c f
If I'm understanding you correctly, this is similar to something I recently filed as a feature request: http://hackage.haskell.org/trac/ghc/ticket/5927 In the meantime it's possible to emulate it to a limited extent with the Sub type from the constraints package: http://hackage.haskell.org/packages/archive/constraints/0.3/doc/html/Data-Co... Out of curiosity, do you have any specific use case in mind?

On 7 Jun 2012, at 20:55, Gábor Lehel wrote:
If I'm understanding you correctly, this is similar to something I recently filed as a feature request:
Yes, that seems to be it. Now I know I'm not alone.
In the meantime it's possible to emulate it to a limited extent with the Sub type from the constraints package:
http://hackage.haskell.org/packages/archive/constraints/0.3/doc/html/Data-Co...
Good. Seems to be enough for me.
Out of curiosity, do you have any specific use case in mind?
It's something like Data types à la carte, but instead of a "sum" of all possible operations I try to use a class.
participants (3)
-
Gábor Lehel
-
MigMit
-
Miguel Mitrofanov