GADTs in implementation of Template Haskell

Richard Eisenberg eir at
Mon Oct 20 18:35:04 UTC 2014

I'm doing a bunch of bug-fixes / improvements to Template Haskell. Two of these are to fix GHC bugs #8100 (add standalone-deriving support) and #9064 (add `default` method type signature support), both of which introduce new constructors for `Dec`. This got me thinking about `Dec` and the fact that different declaration forms are allowable in different contexts. (For example, datatype declarations are allowable only at the top level, and fixity declarations are allowable anywhere except in instance declarations.) How to encode these restrictions? With types, of course! Thus, I redesigned `Dec` to be a GADT.

Having done so, I'm not 100% convinced that this is the right thing to do. I would love feedback on my full, concrete proposal available at  

Is this a change for the better or worse? Feel free either to comment on the wiki page or to this email.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list