Support for data families in generics
Currently DeriveGeneric
doesn't handle data families correctly, so that the following module
{-# LANGUAGE TypeFamilies, DeriveGeneric #-}
module FamilyDerive where
import GHC.Generics
data family F a
data instance F Int = FInt deriving Generic
fails to compile, with error
/tmp/FamilyDerive.hs:6:15:
Couldn't match type `Rep (F Int)' with `M1 t0 t1 (M1 t2 t3 U1)'
The type variables `t0', `t1', `t2', `t3' are ambiguous
Possible fix: add a type signature that fixes these type variable(s)
Expected type: Rep (F Int) x
Actual type: M1 t0 t1 (M1 t2 t3 U1) x
In the pattern: M1 (M1 U1)
In an equation for `to': to (M1 (M1 U1)) = FInt
In the instance declaration for `Generic (F Int)'
It turns out to require only small changes to GHC to handle data families. I've attached patches.
Trac metadata
Trac field | Value |
---|---|
Version | 7.4.1 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |