Opened 6 years ago

Closed 6 years ago

#5686 closed bug (fixed)

'impossible' happened when deriving Functor on a type with a type family application

Reported by: patrick_premont Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.2.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash Test Case: deriving/should_fail/T5686
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


The following should fail with an appropriate error message.

I discovered this by accident when I changed the definition of type 'U' and forgot to remove 'deriving Functor'.

> {-# LANGUAGE TypeFamilies, DeriveFunctor #-}

> data U a = U (G a) deriving Functor
> class A a where
>   type G a

Change History (2)

comment:1 Changed 6 years ago by simonpj@…

commit 88cd0d1fd68ec88dfe843fa14f3895a21e1ca07f

Author: Simon Peyton Jones <>
Date:   Mon Dec 12 08:12:18 2011 +0000

    Make derived functor stuff watch out for type functions (Trac #5686)
    The problem was simply that the side-condition check didn't test for a
    type function, and then splitAppTy fell over.

 compiler/typecheck/TcDeriv.lhs    |    2 +-
 compiler/typecheck/TcGenDeriv.lhs |   57 ++++++++++++++++++++----------------
 2 files changed, 33 insertions(+), 26 deletions(-)

comment:2 Changed 6 years ago by simonpj

difficulty: Unknown
Resolution: fixed
Status: newclosed
Test Case: deriving/should_fail/T5686

Thanks for the report!


Note: See TracTickets for help on using tickets.