[GHC] #1830: Automatic derivation of Lift
GHC
ghc-devs at haskell.org
Mon Aug 24 02:48:02 UTC 2015
#1830: Automatic derivation of Lift
-------------------------------------+-------------------------------------
Reporter: guest | Owner:
| RyanGlScott
Type: feature request | Status: new
Priority: normal | Milestone: ⊥
Component: Template Haskell | Version: 6.8.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Revisions: Phab:D1168
-------------------------------------+-------------------------------------
Changes (by RyanGlScott):
* owner: => RyanGlScott
* differential: => Phab:D1168
Comment:
I have a differential ( Phab:D1168 ) submitted which implements this
feature, but I would like some feedback. I'll copy over my questions from
the Phabricator page:
1. What should we do if someone attempts to derive `Lift` on a datatype
with no constructors? I (somewhat arbitrarily) chose it to generate code
like this:
{{{#!hs
data Void deriving Lift
instance Lift Void where
lift _ = appE (varE 'error) (litE (stringL "Void lift"))
}}}
but {{{lift _ = error "Void lift"}}} would also work.
2. How should primitive data types be handled? I adapted the approach
`Show` takes, which has special cases for `Char#`, `Float#`, `Double#`,
`Int#`, and `Word#`. Note that `template-haskell` also has a `StringPrimL`
constructor, so we could handle `Addr#` as well, but there's not currently
a function of type `String -> [Word8]` in `base` that I could use in
conjunction with it
([http://haddock.stackage.org/lts-3.2/ghc-7.10.2/SMRep.html#v:stringToWord8s
there is in] `ghc`, but I'm not sure if it's verboten to put GHC internals
in derived code).
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/1830#comment:8>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list