[Haskell-cafe] GADTs and Typeclasses

Simon Peyton-Jones simonpj at microsoft.com
Mon Apr 16 02:20:17 EDT 2007


| Will I run into problems using typeclasses with GADTs?

No, you shouldn't, provided you use the HEAD compiler.  I did a fairly major upgrade, after the 6.6 fork, which makes the interaction between type classes and GADTs work properly.  This upgrade isn't in 6.6, and I regard the type-class/GADT interaction as broken in 6.6.   That said, most programs work just fine -- you'll only notice if you push the boundary.

Simon

| I've come up with this
| to model a fragment of ASN.1. I'd hate to spend a lot of time on this only to
| find out it's well known that these two features don't mix very well.
|
| Thanks, Dominic.
|
| data Type :: * -> * where
|    INTEGER             :: Type Int
|    BOOLEAN             :: Type Bool
|    BITSTRING           :: Type BitString
|    NUMERICSTRING       :: Type NumericString
|    ReferencedType      :: Type () -- for now
|    ConstrainedType     :: Type a -> Constraint a -> Type a
|    SizeConstrainedType :: Size a => Type a -> Constraint Int -> Type a
|    FromConstrainedType :: From a => Type a -> Constraint a -> Type a


More information about the Haskell-Cafe mailing list