Opened 5 years ago

Closed 5 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: Difficulty: Unknown
Test Case: deriving/should_compile/T3057 Blocked By:
Blocking: Related Tickets:

Description

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 )

Test.hs:9:0:
    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 5 years ago by simonpj

  • Difficulty set to Unknown
  • Resolution set to fixed
  • Status changed from new to closed
  • Test Case set to deriving/should_compile/T3057

Good bug thanks. Fixed by

Tue Mar  3 09:06:12 PST 2009  simonpj@microsoft.com
  * 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
  FFoldType.

I added a test too.

Simon

Note: See TracTickets for help on using tickets.