#4220: EmptyDataDecls + DeriveFunctor == Panic!
---------------------------------+------------------------------------------
Reporter: conal | Owner: conal
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.12.3
Keywords: | Difficulty:
Os: Unknown/Multiple | Testcase:
Architecture: Unknown/Multiple | Failure: Compile-time crash
---------------------------------+------------------------------------------
Comment(by simonpj):
Ah yes. I have a fix in my tree. Conal, did becoming the "owner" mean
that you intended to submit a patch?
My fix generates a catch-all equation for fmap
{{{
fmap _ a = unsafeCoerce# a
}}}
in two cases:
* When there are no constructors
* When there are any constructors that don't mention the "active" type
variable at all
The latter case is to catch a situation like this
{{{
data T a b = T1 b | T2 a | T3 a | T4 a | T5
}}}
The "active" type variable is the last one in type, "b" in this case.
Here it seems a waste to pattern-match on T2-T5 (as the current 6.12
does).
Better to say
{{{
fmap f (T1 x) = T1 (f x)
fmap _ a = unsafeCoerce# a
}}}
The coerce is necessary to change the type, of course.
Does that seem right?
There must be something similar for `Foldable` and `Traversable`, not just
`Functor`, and we'd better fix them at the same time:
* I believe the criterion is the same: that is, any data constructors
whose argument types do not mention the active type variable can be
treated uniformly with a no-op.
* I'm not sure what the code for a no-op for `Foldable` and `Traversable`
are. Can someone say, please?
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4220#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs