RFC: explicit support for GADTs in Template Haskell

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

RFC: explicit support for GADTs in Template Haskell

Jan Stolarek
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
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: RFC: explicit support for GADTs in Template Haskell

Roman Cheplyaka-2
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
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: RFC: explicit support for GADTs in Template Haskell

Jan Stolarek
> Shouldn't it be represented the same way as in GHC's own AST?
My personal opinion is that it should. But I wanted to hear what others have to say. If there is a
strong bias towards option (2) I will re-consider my design decision.

Janek

> 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
> > [hidden email]
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe



---
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
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe