Superclass Cycle via Associated Type

Dan Doel dan.doel at gmail.com
Fri Jul 22 21:35:45 CEST 2011


2011/7/22 Gábor Lehel <illissius at gmail.com>:
> Yeah, this is pretty much what I ended up doing. As I said, I don't
> think I lose anything in expressiveness by going the MPTC route, I
> just think the two separate but linked classes way reads better. So
> it's just a "would be nice" thing. Do recursive equality superclasses
> make sense / would they be within the realm of the possible to
> implement?

Those equality superclasses are not recursive in the same way, as far
as I can tell. The specifications for classes require that there is no
chain:

    C ... => D ... => E ... => ... => C ...

However, your example just had (~) as a context for C, but C is not
required by (~). And the families involved make no reference to C,
either. A fully desugared version looks like:

    type family Frozen a :: *
    type family Thawed a :: *

    class (..., Thawed (Frozen t) ~ t) => Mutable t where ...

I think this will be handled if you use a version where equality
superclasses are allowed.

-- Dan



More information about the Glasgow-haskell-users mailing list