Newtype deriving mixing up types
simonpj at microsoft.com
Fri Dec 17 09:49:21 CET 2010
Yes, it's a bug all right. See http://hackage.haskell.org/trac/ghc/ticket/4846
| -----Original Message-----
| From: glasgow-haskell-users-bounces at haskell.org [mailto:glasgow-haskell-
| users-bounces at haskell.org] On Behalf Of Emil Axelsson
| Sent: 16 December 2010 13:26
| To: glasgow-haskell-users at haskell.org
| Subject: Newtype deriving mixing up types
| 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
| instance B BOOL
| the result is correct.
| Tested with both 6.12.3 and 7.0.1.
| Should I report this as a bug?
| / Emil
More information about the Glasgow-haskell-users