[Template-haskell] GADTs

Ian Lynagh igloo at earth.li
Fri Aug 11 18:25:02 EDT 2006


Hi all,

Currently we do not have GADT support in Template Haskell, but I need it
for something I'm working on. The relevant datastructures currently look
like this:

    data Dec = ...
             | DataD Cxt Name [Name] [Con] [Name]
             | ...

    data Con = NormalC Name [StrictType]
             | RecC Name [VarStrictType]
             | InfixC StrictType Name StrictType
             | ForallC [Name] Cxt Con

I propose altering Dec thus:

    data Dec = ...
             | DataD Cxt Name [Name] Cons [Name]
             | ...

(changing [Con] to Cons) and adding new datastructures:

    data Cons = NormalCons [Con]
              | GadtCons [GadtCon]
             deriving( Show, Eq )

    data GadtCon = GadtC [Name] Cxt Name [StrictType] Type
             deriving( Show, Eq )

(this follows the style used to add pattern guards to the
datastructures). Complete patches for GHC and the template-haskell
library are at http://urchin.earth.li/~ian/th-gadts/

If you have any objections or comments then please let me know;
otherwise I think it would be great to get this into GHC 6.6.


Thanks
Ian



More information about the template-haskell mailing list