[GHC] #10831: Document conditions on deriving Functor (was: DeriveFunctor not capable of deriving when wrapping Either)
GHC
ghc-devs at haskell.org
Tue Sep 8 17:47:06 UTC 2015
#10831: Document conditions on deriving Functor
-------------------------------------+-------------------------------------
Reporter: htebalaka | Owner:
Type: bug | Status: new
Priority: low | Milestone:
Component: Compiler (Type | Version: 7.10.2
checker) |
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Documentation | Unknown/Multiple
bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Revisions:
-------------------------------------+-------------------------------------
Changes (by rwbarton):
* failure: GHC rejects valid program => Documentation bug
Comment:
Right, this is expected behavior. The compiler doesn't "look inside" the
definitions of other data types when deriving Functor, it relies on
Functor instances for those types. But that is not enough to handle the
occurrence of `b` inside the first argument to `Either`. One would need
another class
{{{
class Functor1 f where
fmap1 :: (a -> b) -> f a x -> f b x
instance Functor1 Either
}}}
I note that there is no documentation in the User's Guide about when
deriving Functor will succeed. That at least should be fixed, so I'm
repurposing this ticket. Feel free to also submit a feature request if you
like.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10831#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list