[Haskell-cafe] Inheritance constraints

Gábor Lehel illissius at gmail.com
Thu Jun 7 18:55:11 CEST 2012

On Thu, Jun 7, 2012 at 1:42 PM, Miguel Mitrofanov <miguelimo38 at yandex.ru> wrote:
> 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:


In the meantime it's possible to emulate it to a limited extent with
the Sub type from the constraints package:


Out of curiosity, do you have any specific use case in mind?

More information about the Haskell-Cafe mailing list