Opened 9 years ago

Closed 9 years ago

#3057 closed bug (fixed)

Standalone deriving of Functor does not work for HsDoc

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


I tried to use the new DerivingFunctor extension to derive Functor for the HsDoc type from the ghc package:

{-# StandaloneDeriving, DerivingFunctor #-}

import HsDoc

deriving instance Functor HsDoc

But I got this error message:

david@david-laptop:~/dev/test$ /home/david/ghc-head/bin/ghc --make Test.hs -package ghc
[1 of 1] Compiling Test             ( Test.hs, Test.o )

    Couldn't match expected type `b' against inferred type `a'
      `b' is a rigid type variable bound by
          the type signature for `fmap' at <no location info>
      `a' is a rigid type variable bound by
          the type signature for `fmap' at <no location info>
      Expected type: HsDoc b
      Inferred type: HsDoc a
    In the first argument of `DocAppend', namely `a1'
    In the expression: DocAppend a1 a2

Change History (1)

comment:1 Changed 9 years ago by simonpj

difficulty: Unknown
Resolution: fixed
Status: newclosed
Test Case: deriving/should_compile/T3057

Good bug thanks. Fixed by

Tue Mar  3 09:06:12 PST 2009
  * Fix Trac #3057 in deriving Functor
  Ignore-this: 7d7783868e4684930f75c3b35c18c586

  The universal type variables of a data constructor are not necessarily
  identical to those of its parent type constructor, especially if the
  data type is imported.

  While I was at it, I did a significant refactoring to make all this
  traversal of types more comprehensible, by adding the data type

I added a test too.


Note: See TracTickets for help on using tickets.