[GHC] #15961: TH 'Lift' instance for 'NonEmpty'

#15961: TH 'Lift' instance for 'NonEmpty' -------------------------------------+------------------------------------- Reporter: fr33domlover | Owner: (none) Type: feature | Status: new request | Priority: normal | Milestone: 8.6.3 Component: Template | Version: 8.6.2 Haskell | Keywords: lift, | Operating System: Unknown/Multiple instance, nonempty | Architecture: | Type of failure: Other Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I was using `deriving Lift` on a data type and the `DeriveLift` extension: {{{#!hs import Data.List.NonEmpty import Language.Haskell.TH data T = T (NonEmpty String) Int }}} and I noticed I couldn't get an automatic instance because `NonEmpty` doesn't have a `Lift` instance. I'm wondering if an instance can be added to the `template-haskell` package (or elsewhere if that isn't the right place? I'm assuming it is because `NonEmpty` is in `base` now) Since `NonEmpty` has a `Data` instance, I suppose the following would be enough? {{{#!hs instance Data a => Lift (NonEmpty a) }}} And without using `Data` it could be: {{{#!hs nonemptyConName :: Name nonemptyConName = mkNameG DataName "base" "Data.List.NonEmpty" ":|" instance Lift a => Lift (NonEmpty a) where lift (x :| xs) = do x' <- lift x xs' <- traverse lift xs return $ ConE nonemptyConName `AppE` x' `AppE` xs' }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15961 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15961: TH 'Lift' instance for 'NonEmpty' -------------------------------------+------------------------------------- Reporter: fr33domlover | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: 8.6.3 Component: Template Haskell | Version: 8.6.2 Resolution: | Keywords: lift, | instance, nonempty Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by fr33domlover: Old description:
I was using `deriving Lift` on a data type and the `DeriveLift` extension:
{{{#!hs import Data.List.NonEmpty import Language.Haskell.TH
data T = T (NonEmpty String) Int }}}
and I noticed I couldn't get an automatic instance because `NonEmpty` doesn't have a `Lift` instance. I'm wondering if an instance can be added to the `template-haskell` package (or elsewhere if that isn't the right place? I'm assuming it is because `NonEmpty` is in `base` now)
Since `NonEmpty` has a `Data` instance, I suppose the following would be enough?
{{{#!hs instance Data a => Lift (NonEmpty a) }}}
And without using `Data` it could be:
{{{#!hs nonemptyConName :: Name nonemptyConName = mkNameG DataName "base" "Data.List.NonEmpty" ":|"
instance Lift a => Lift (NonEmpty a) where lift (x :| xs) = do x' <- lift x xs' <- traverse lift xs return $ ConE nonemptyConName `AppE` x' `AppE` xs' }}}
New description: I was using `deriving Lift` on a data type and the `DeriveLift` extension: {{{#!hs import Data.List.NonEmpty import Language.Haskell.TH data T = T (NonEmpty String) Int deriving Lift }}} and I noticed I couldn't get an automatic instance because `NonEmpty` doesn't have a `Lift` instance. I'm wondering if an instance can be added to the `template-haskell` package (or elsewhere if that isn't the right place? I'm assuming it is because `NonEmpty` is in `base` now) Since `NonEmpty` has a `Data` instance, I suppose the following would be enough? {{{#!hs instance Data a => Lift (NonEmpty a) }}} And without using `Data` it could be: {{{#!hs nonemptyConName :: Name nonemptyConName = mkNameG DataName "base" "Data.List.NonEmpty" ":|" instance Lift a => Lift (NonEmpty a) where lift (x :| xs) = do x' <- lift x xs' <- traverse lift xs return $ ConE nonemptyConName `AppE` x' `AppE` xs' }}} -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15961#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15961: TH 'Lift' instance for 'NonEmpty' -------------------------------------+------------------------------------- Reporter: fr33domlover | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: 8.6.3 Component: Template Haskell | Version: 8.6.2 Resolution: | Keywords: lift, | instance, nonempty Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by harpocrates): Please avoid using the default `Data` implementations of `Lift` (or at least explicitly define `lift = liftData`). For existing code, I would use `-XStandaloneDeriving` and `-XDeriveLift`. {{{ deriving instance Lift a => Lift (NonEmpty a) }}} I agree we should put instances in `template-haskell` now that `NonEmpty` is in `base`. I'll put up a patch and we can see what others think. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15961#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15961: TH 'Lift' instance for 'NonEmpty' -------------------------------------+------------------------------------- Reporter: fr33domlover | Owner: (none) Type: feature request | Status: patch Priority: normal | Milestone: 8.6.3 Component: Template Haskell | Version: 8.6.2 Resolution: | Keywords: lift, | instance, nonempty Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5391 Wiki Page: | -------------------------------------+------------------------------------- Changes (by harpocrates): * status: new => patch * differential: => Phab:D5391 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15961#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15961: TH 'Lift' instance for 'NonEmpty'
-------------------------------------+-------------------------------------
Reporter: fr33domlover | Owner: (none)
Type: feature request | Status: patch
Priority: normal | Milestone: 8.6.3
Component: Template Haskell | Version: 8.6.2
Resolution: | Keywords: lift,
| instance, nonempty
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: Other | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D5391
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ryan Scott

#15961: TH 'Lift' instance for 'NonEmpty' -------------------------------------+------------------------------------- Reporter: fr33domlover | Owner: (none) Type: feature request | Status: closed Priority: normal | Milestone: 8.8.1 Component: Template Haskell | Version: 8.6.2 Resolution: fixed | Keywords: lift, | instance, nonempty Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5391 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: patch => closed * resolution: => fixed * milestone: 8.6.3 => 8.8.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15961#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC