Opened 9 years ago

Closed 9 years ago

#4816 closed bug (fixed)

DeriveFunctor should not require a functor instance for functorial data types used invariantly

Reported by: batterseapower Owned by:
Priority: normal Milestone: 7.2.1
Component: Compiler Version: 6.12.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: deriving/should_compile/T4816
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


This program:

{-# LANGUAGE DeriveFunctor #-}
data Silly a = Sillly a

data Baz o = Baz {
    foo :: o,
    bar :: Silly ()
  } deriving (Functor)

Produces this error:

    No instance for (Functor Silly)
      arising from the 'deriving' clause of a data type declaration
                   at /Users/mbolingbroke/Junk/Repro2.hs:7:14-20
    Possible fix:
      add an instance declaration for (Functor Silly)
      or use a standalone 'deriving instance' declaration instead,
         so you can specify the instance context yourself
    When deriving the instance for (Functor Baz)

But there is absolutely no need for such an instance, because I'm not using "Silly a", just "Silly ()".

Change History (3)

comment:1 Changed 9 years ago by simonpj

Status: newmerge
Test Case: deriving/should_compile/T4816

Right. This is a bug, easily fixed.

Wed Dec 15 12:37:25 GMT 2010
  * Fix a bug in functorLikeTraverse, which was giving wrong answer for tuples
  This bug led to Trac #4816, which is hereby fixed

    M ./compiler/typecheck/TcDeriv.lhs -1 +1
    M ./compiler/typecheck/TcGenDeriv.lhs -5 +7

I've added a test

merge when convenient.


comment:2 Changed 9 years ago by igloo

Milestone: 7.0.3

comment:3 Changed 9 years ago by igloo

Resolution: fixed
Status: mergeclosed


Note: See TracTickets for help on using tickets.