Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#9563 closed bug (fixed)

Support for deriving Generic1 for data families

Reported by: mnislaih Owned by: dreixel
Priority: high Milestone: 7.8.4
Component: Compiler Version: 7.8.2
Keywords: Generics Cc:
Operating System: MacOS X Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Test Case: generics/T9563
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


The following code:

import GHC.Generics

data family F typ :: * -> *
data A
data instance F A a = AData a deriving Generic1

produces an error when run with ghc 7.8.2 or 7.8.3:

Couldn't match type ‘Rep1 (F A)’
              with ‘M1 t0 t1 (M1 t2 t3 (M1 t4 t5 Par1))’
The type variables ‘t0’, ‘t1’, ‘t2’, ‘t3’, ‘t4’, ‘t5’ are ambiguous
Expected type: Rep1 (F A) a
  Actual type: M1 t0 t1 (M1 t2 t3 (M1 t4 t5 Par1)) a
In the pattern: M1 (M1 (M1 g1))
In an equation for ‘to1’: to1 (M1 (M1 (M1 g1))) = AData (unPar1 g1)
In the instance declaration for ‘Generic1 (F A)’

whereas ghc 7.6.3 simply refuses to go ahead with the message:

    Derived instance `Generic1 (F A)'
      requires illegal partial application of data type family F
    In the data instance declaration for `F'

Either a check has gone missing in 7.8.x, or a bug has crept up in the Generic1 support. I have gone through past tickets and suggests that it is the latter.

Change History (7)

comment:1 Changed 5 years ago by simonpj

Milestone: 7.10.1
Owner: set to dreixel
Priority: normalhigh

Pedro, might you look at this?


comment:2 Changed 5 years ago by Jose Pedro Magalhaes <jpm@…>

In 946cbcefab9bc02e12b741e5b070d7521b37ba1a/ghc:

Fix support for deriving Generic1 for data families (FIX #9563)

comment:3 Changed 5 years ago by dreixel

Status: newmerge
Test Case: generics/T9563

Thanks for reporting. That code now compiles with HEAD.

comment:4 Changed 5 years ago by thomie


I don't know whether this actually needs to go into 7.8.4, but status=merge and milestone=7.10.1 doesn't make sense (there's no 7.10 branch yet, so there's nothing to merge).

comment:5 Changed 5 years ago by dreixel

Thanks. Merging into 7.8.4 would be good, if possible.

comment:6 Changed 5 years ago by thoughtpolice

Resolution: fixed
Status: mergeclosed

Merged to 7.8.4.

comment:7 Changed 4 years ago by RyanGlScott

Keywords: Generics added
Note: See TracTickets for help on using tickets.