
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 https://ghc.haskell.org/trac/ghc/wiki/Design/TemplateHaskellGADTs Is this a change for the better or worse? Feel free either to comment on the wiki page or to this email. Thanks! Richard

On October 20, 2014 at 2:35:27 PM, Richard Eisenberg (eir@cis.upenn.edu) wrote:
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 https://ghc.haskell.org/trac/ghc/wiki/Design/TemplateHaskellGADTs
Is this a change for the better or worse? Feel free either to comment on the wiki page or to this email.
Thanks! Richard
As I understand it, the big downsides are that we don’t get `gunfold` for Dec and Pragma, and we may not get `Generic` instances for them at all. At first this felt pretty bad, but then I reviewed how generics and TH tend to get used together, and now I’m not _quite_ as anxious. In my mind the main use case for them is in things like this: http://www.well-typed.com/blog/2014/10/quasi-quoting-dsls/ — skimming the code involved, and the way `dataToExpQ` and friends tend to work, the key bit is having the generic instances on what we’re inducting on, not what we’re building… By the time we hit concrete TH syntax, it feels a bit late to be doing further generic transformations on it, so I have a suspicion this won’t hit anyone. I certainly don’t think it’ll affect _my_ uses of TH at least :-) Cheers, Gershom
participants (2)
-
Gershom B
-
Richard Eisenberg