
#10598: DeriveAnyClass and GND don't work well together -------------------------------------+------------------------------------- Reporter: osa1 | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by osa1): Oh you're right. I forgot that DeriveAnyClass should never fail, so maybe there are multiple bugs involved. I managed to modify GHC to make this program work: {{{ ➜ deriveany_bug cat Test.hs newtype MyMaybe a = MyMaybe (Maybe a) deriving (Functor, Show) main = print $ MyMaybe $ Just (10 :: Int) ➜ deriveany_bug ghc-stage1 --make Test.hs -fforce-recomp -XDeriveAnyClass [1 of 1] Compiling Main ( Test.hs, Test.o ) Linking Test ... ➜ deriveany_bug ./Test MyMaybe (Just 10) ➜ deriveany_bug ghc-stage1 --make Test.hs -fforce-recomp -XDeriveAnyClass -XGeneralizedNewtypeDeriving [1 of 1] Compiling Main ( Test.hs, Test.o ) Test.hs:2:13: warning: Both DeriveAnyClass and GeneralizedNewtypeDeriving are enabled Defaulting to the DeriveAnyClass strategy for instantiating Functor In the newtype declaration for ‘MyMaybe’ Test.hs:2:22: warning: Both DeriveAnyClass and GeneralizedNewtypeDeriving are enabled Defaulting to the DeriveAnyClass strategy for instantiating Show In the newtype declaration for ‘MyMaybe’ Linking Test ... ➜ deriveany_bug ./Test MyMaybe (Just 10) }}} `mkNewTypeEqn` function has some error handling for the cases where we have both GND and DeriveAnyClass, but the logic is buggy, I think. It's easy to fix. (I didn't run the whole test suite though, I'm not 100% sure I didn't break anything) Should I send a patch for reviews or do you think the problem is something else? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10598#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler