Newtype deriving mixing up types
Emil Axelsson
emax at chalmers.se
Thu Dec 16 14:26:23 CET 2010
Hello!
I attach a program which I suspect demonstrates a bug in GHC. The
important lines are:
showType :: forall a . Expr a -> String
showType (Lit _) = show (typeOf (undefined :: a))
test1 = showType (mk :: Expr BOOL) -- Prints "Bool" (wrong?)
test2 = showType (Lit mk :: Expr BOOL) -- Prints "Main.BOOL" (correct)
test1 and test2 give different results, even though showType shouldn't
be able to tell them apart. It seems that the Typeable context packed
with the Lit constructor is wrong in test2.
I had to use two extra classes and newtype deriving to trigger this
behavior. Note that if I change
deriving instance B BOOL
to
instance B BOOL
the result is correct.
Tested with both 6.12.3 and 7.0.1.
Should I report this as a bug?
Thanks!
/ Emil
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Bug.hs
Type: text/x-haskell
Size: 594 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20101216/a342b1f5/attachment.hs>
More information about the Glasgow-haskell-users
mailing list