Proposal: Derive Lift for all data types in the template-haskell library

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

Proposal: Derive Lift for all data types in the template-haskell library

Ryan Scott
The DeriveLift extension has landed in GHC HEAD, so now it's become apparent that the bikeshed needs a new coat of paint. The only Lift instances at the moment are base types [1], but with DeriveLift, it would be possible to implement Lift for many for data types with ease.

I'll make (what I hope is) an uncontroversial first suggestion: we should derive Lift for every data type in the template-haskell library itself. These instances have proved to be useful for library authors who need to convert to and from the TH AST (th-desugar, for example, relies on this functionality via orphan instances [2]).

Adding this would break some code out in the wild (the th-lift [3] and th-orphans [4] packages come to mind; there may be others), so I'll request feedback before marching forth with this proposal.

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Derive Lift for all data types in the template-haskell library

Richard Eisenberg-2
+1 from me. Now that it's so easy, I think Lift should be instanced for all concrete types exported from the boot libraries. Do make sure to communicate with the authors of th-lift and th-orphans at some point, though.

Richard

On Sep 22, 2015, at 10:12 AM, Ryan Scott <[hidden email]> wrote:

The DeriveLift extension has landed in GHC HEAD, so now it's become apparent that the bikeshed needs a new coat of paint. The only Lift instances at the moment are base types [1], but with DeriveLift, it would be possible to implement Lift for many for data types with ease.

I'll make (what I hope is) an uncontroversial first suggestion: we should derive Lift for every data type in the template-haskell library itself. These instances have proved to be useful for library authors who need to convert to and from the TH AST (th-desugar, for example, relies on this functionality via orphan instances [2]).

Adding this would break some code out in the wild (the th-lift [3] and th-orphans [4] packages come to mind; there may be others), so I'll request feedback before marching forth with this proposal.
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Derive Lift for all data types in the template-haskell library

Michael Sloan
+1,ideally, th-orphans would be essentially empty for newer GHCs (and so just be a compatibility shim for also getting the instances with older TH)

Actually, oddly enough, th-orphans ought to not be broken by this.  Other than a number of Lift instances for numeric types, here's how it defines all its Lift instances:

$(reifyManyWithoutInstances ''Lift [''Info, ''Loc] (const True) >>= deriveLiftMany)

This recursively derives Lift for every datatype transitively, but only if they don't already have a Lift instance.  I'd been hoping to use this for everything in th-orphans, but unfortunately older versions of TH don't support standalone deriving.

Michael

On Tue, Sep 22, 2015 at 5:59 PM Richard Eisenberg <[hidden email]> wrote:
+1 from me. Now that it's so easy, I think Lift should be instanced for all concrete types exported from the boot libraries. Do make sure to communicate with the authors of th-lift and th-orphans at some point, though.

Richard

On Sep 22, 2015, at 10:12 AM, Ryan Scott <[hidden email]> wrote:

The DeriveLift extension has landed in GHC HEAD, so now it's become apparent that the bikeshed needs a new coat of paint. The only Lift instances at the moment are base types [1], but with DeriveLift, it would be possible to implement Lift for many for data types with ease.

I'll make (what I hope is) an uncontroversial first suggestion: we should derive Lift for every data type in the template-haskell library itself. These instances have proved to be useful for library authors who need to convert to and from the TH AST (th-desugar, for example, relies on this functionality via orphan instances [2]).

Adding this would break some code out in the wild (the th-lift [3] and th-orphans [4] packages come to mind; there may be others), so I'll request feedback before marching forth with this proposal.
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Derive Lift for all data types in the template-haskell library

Ryan Scott
Hm, it looks like I proposed this much earlier than I probably should have, since I forgot that the GHC boot libraries have to be buildable by the last two major releases of GHC anyway [1], and since template-haskell is a stage-0 dependency, adding -XDeriveLift to template-haskell is a no-go at the moment.

But I can at least look forward to having this in GHC 8.4 in a couple of years :)

Ryan S.

On Wed, Sep 23, 2015 at 12:16 AM, Michael Sloan <[hidden email]> wrote:
+1,ideally, th-orphans would be essentially empty for newer GHCs (and so just be a compatibility shim for also getting the instances with older TH)

Actually, oddly enough, th-orphans ought to not be broken by this.  Other than a number of Lift instances for numeric types, here's how it defines all its Lift instances:

$(reifyManyWithoutInstances ''Lift [''Info, ''Loc] (const True) >>= deriveLiftMany)

This recursively derives Lift for every datatype transitively, but only if they don't already have a Lift instance.  I'd been hoping to use this for everything in th-orphans, but unfortunately older versions of TH don't support standalone deriving.

Michael

On Tue, Sep 22, 2015 at 5:59 PM Richard Eisenberg <[hidden email]> wrote:
+1 from me. Now that it's so easy, I think Lift should be instanced for all concrete types exported from the boot libraries. Do make sure to communicate with the authors of th-lift and th-orphans at some point, though.

Richard

On Sep 22, 2015, at 10:12 AM, Ryan Scott <[hidden email]> wrote:

The DeriveLift extension has landed in GHC HEAD, so now it's become apparent that the bikeshed needs a new coat of paint. The only Lift instances at the moment are base types [1], but with DeriveLift, it would be possible to implement Lift for many for data types with ease.

I'll make (what I hope is) an uncontroversial first suggestion: we should derive Lift for every data type in the template-haskell library itself. These instances have proved to be useful for library authors who need to convert to and from the TH AST (th-desugar, for example, relies on this functionality via orphan instances [2]).

Adding this would break some code out in the wild (the th-lift [3] and th-orphans [4] packages come to mind; there may be others), so I'll request feedback before marching forth with this proposal.
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Derive Lift for all data types in the template-haskell library

Richard Eisenberg-2
Excellent point. We could, if we wanted, use some custom code (or -ddump-deriv? or th-lift and -ddump-splices?) to generate all the Lift instances and then add them by hand. I wouldn't want to maintain these instances indefinitely, but now that it's not indefinite, I'm OK.

But I'm also not dying for the instances to begin with. So we could just table the discussion for a few years until we're ready to use 8.0 for bootstrapping.

Richard

On Sep 26, 2015, at 12:52 PM, Ryan Scott <[hidden email]> wrote:

Hm, it looks like I proposed this much earlier than I probably should have, since I forgot that the GHC boot libraries have to be buildable by the last two major releases of GHC anyway [1], and since template-haskell is a stage-0 dependency, adding -XDeriveLift to template-haskell is a no-go at the moment.

But I can at least look forward to having this in GHC 8.4 in a couple of years :)

Ryan S.

On Wed, Sep 23, 2015 at 12:16 AM, Michael Sloan <[hidden email]> wrote:
+1,ideally, th-orphans would be essentially empty for newer GHCs (and so just be a compatibility shim for also getting the instances with older TH)

Actually, oddly enough, th-orphans ought to not be broken by this.  Other than a number of Lift instances for numeric types, here's how it defines all its Lift instances:

$(reifyManyWithoutInstances ''Lift [''Info, ''Loc] (const True) >>= deriveLiftMany)

This recursively derives Lift for every datatype transitively, but only if they don't already have a Lift instance.  I'd been hoping to use this for everything in th-orphans, but unfortunately older versions of TH don't support standalone deriving.

Michael

On Tue, Sep 22, 2015 at 5:59 PM Richard Eisenberg <[hidden email]> wrote:
+1 from me. Now that it's so easy, I think Lift should be instanced for all concrete types exported from the boot libraries. Do make sure to communicate with the authors of th-lift and th-orphans at some point, though.

Richard

On Sep 22, 2015, at 10:12 AM, Ryan Scott <[hidden email]> wrote:

The DeriveLift extension has landed in GHC HEAD, so now it's become apparent that the bikeshed needs a new coat of paint. The only Lift instances at the moment are base types [1], but with DeriveLift, it would be possible to implement Lift for many for data types with ease.

I'll make (what I hope is) an uncontroversial first suggestion: we should derive Lift for every data type in the template-haskell library itself. These instances have proved to be useful for library authors who need to convert to and from the TH AST (th-desugar, for example, relies on this functionality via orphan instances [2]).

Adding this would break some code out in the wild (the th-lift [3] and th-orphans [4] packages come to mind; there may be others), so I'll request feedback before marching forth with this proposal.
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries



_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries