
#9444: -ddump-deriv doesn't dump failed newtype-deriving -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): Think about {{{ data T = MkT Int Int Bool (Int -> Bool) deriving( Read ) }}} You probably ''don't'' want to see the parser code generated by a derived `Read` instance. What you want to know is that the derived instance needs `Read` on each constructor argument. {{{ T9444.hs:6:37: No instance for (Read (Int -> Bool)) arising from the first field of ‘MkT’ (type ‘Int -> Int’) Possible fix: use a standalone 'deriving instance' declaration, so you can specify the instance context yourself When deriving the instance for (Read T) }}} It's the same for deriving `C`. What you need to know is that we need a `Coercible (Int -> F Int) (Age -> F Age)` for each method of `C`. (Here there is just one.) And that is what fails: {{{ T9444.hs:16:12: Could not coerce from ‘Bool’ to ‘F Age’ because ‘Bool’ and ‘F Age’ are different types. arising from the coercion of the method ‘meth’ from type ‘Int -> F Int’ to type ‘Age -> F Age’ Possible fix: use a standalone 'deriving instance' declaration, so you can specify the instance context yourself When deriving the instance for (C Age) }}} I think it's a pretty good error message! I suppose the `arising from` part could say: {{{ arising from the derived definition of method 'meth': instance ... => C Age where meth = coerce meth }}} but I'm not sure that will be much better, would it? Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9444#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler