#4846: Newtype derving used wrongly
---------------------------------+------------------------------------------
Reporter: simonpj | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.0.1
Keywords: | Testcase:
Blockedby: | Difficulty:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
Changes (by simonpj):
* cc: sweir...@…, dimit...@… (added)
Comment:
Good catch. I had a look, and it turns out to be another example of the
nasty #1496 newtype-deriving bug.
In this case, GHC is making this type equality:
{{{
Expr Bool ~ Expr BOOL
}}}
But the equality isn't right, because `Expr` captures a `Typeable`
dictionary that can see what type the term has.
This bug has been long un-fixed because I've been quite unsure what the
right fix is. Happily I think we now know; see our POPL 2011 paper
[http://www.cis.upenn.edu/~sweirich/newtypes.pdf Generative Type
Abstraction and Type-level Computation].
Of course, there is the small matter of implementing the ideas in the
paper, which in turn is queued up behind a number of other type-system
implementation tasks. So don't hold your breath. (The workaround is not
to use newtype deriving for `(B BOOL)`.)
The paper only deals with type functions, but your example shows that we
must be equally careful with type classes. Thank you for that.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4846#comment:1>
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