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

Roman Cheplyaka roma at ro-che.info
Mon Dec 21 18:30:22 UTC 2015


Hi Janek,

Shouldn't it be represented the same way as in GHC's own AST? Especially
regarding a recent thread about unifying the two (IIRC).

On 12/21/2015 07:52 PM, Jan Stolarek wrote:
> 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 
> explicity. 
> 
> 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
> 
> Janek
> 
> ---
> 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.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20151221/1bc73260/attachment.sig>


More information about the Haskell-Cafe mailing list