Ticket #5936 (closed feature request: fixed)
Support for data families in generics
| Reported by: | reinerp | Owned by: | dreixel |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.6.1 |
| Component: | Compiler | Version: | 7.4.1 |
| Keywords: | Cc: | patrick@…, bgamari@… | |
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | None/Unknown | Difficulty: | Unknown |
| Test Case: | generics/GEq1, generics/GenCanDoRep0 | Blocked By: | |
| Blocking: | Related Tickets: |
Description
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.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

