[GHC] #15969: Generic1 deriving should use more coercions
GHC
ghc-devs at haskell.org
Thu Nov 29 05:51:51 UTC 2018
#15969: Generic1 deriving should use more coercions
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.8.1
Component: Compiler | Version: 8.6.2
Resolution: | Keywords: Generics
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by dfeuer):
I think this problem suggests that `Generic1` got composition the wrong
way around. Let's take a slightly bigger example:
{{{#!hs
data Baz a = Baz (Maybe [Either Int a])
}}}
We currently derive
{{{#!hs
Rep1 Baz = ... (Maybe :.: ([] :.: Rec1 (Either Int)))
}}}
Suppose we did it the other way:
{{{#!hs
Rep1 Baz = .... ((Rec1 Maybe :.: []) :.: Either Int)
}}}
then we'd have the `Rec1` "exposed" properly:
{{{#!hs
from1 (Baz q) = M1 (M1 (M1 (Comp1 (Comp1 (Rec1 q)))))
}}}
No fanciness required at all!
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15969#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list