[Haskell-cafe] RFC: explicit support for GADTs in Template Haskell

Jan Stolarek jan.stolarek at p.lodz.pl
Mon Dec 21 17:52:34 UTC 2015

GHC Users,

I am working on adding proper support for GADTs in Template Haskell. By proper I mean that GADTs 
data constructors will no longer be encoded using H98 data constructors, but will be represented 

GADTs allow to declare several constructors with the same signature:

data T where
  MkT1, MkT2 :: T

The question is whether to represent such constructors in TH syntax as:

  (1) GadtC [Name] [StrictType] Name [Type]  -- or:
  (2) GadtC  Name  [StrictType] Name [Type]

Note the difference in first field. (1) is closer to the original syntax, as it stores the list of 
all names in a single declaration, as was originally written in the source code. (2) requires to 
have a separate `GadtC` for each constructor even if constructors were declared together, as in 
the example above.

I would like to hear from TH users which of these two representations you prefer. At the moment I 
have implemented (1) as it directly represents source syntax. The downside of (1) is that 
information whether several data constructors were declared together is not recoverable during 
reification, and so reifying T will yield:

data T where
  MkT1 :: T
  MkT2 :: T


Politechnika Łódzka
Lodz University of Technology

Treść tej wiadomości zawiera informacje przeznaczone tylko dla adresata.
Jeżeli nie jesteście Państwo jej adresatem, bądź otrzymaliście ją przez pomyłkę
prosimy o powiadomienie o tym nadawcy oraz trwałe jej usunięcie.

This email contains information intended solely for the use of the individual to whom it is addressed.
If you are not the intended recipient or if you have received this message in error,
please notify the sender and delete it from your system.

More information about the Haskell-Cafe mailing list