
Yes, it's a bug all right. See http://hackage.haskell.org/trac/ghc/ticket/4846 Thanks Simon | -----Original Message----- | From: glasgow-haskell-users-bounces@haskell.org [mailto:glasgow-haskell- | users-bounces@haskell.org] On Behalf Of Emil Axelsson | Sent: 16 December 2010 13:26 | To: glasgow-haskell-users@haskell.org | Subject: Newtype deriving mixing up types | | 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