[GHC] #9444: -ddump-deriv doesn't dump failed newtype-deriving

#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 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Unknown | Type of failure: Blocked By: | None/Unknown Related Tickets: | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- When I say {{{#!hs {-# LANGUAGE GeneralizedNewtypeDeriving, TypeFamilies #-} {-# OPTIONS_GHC -ddump-deriv #-} type family F a type instance F Int = Bool class C a where meth :: a -> F a instance C Int where meth = (> 0) newtype Age = MkAge Int deriving C }}} I get an error (which I should), but I don't get the derived `C` instance, as requested by `-ddump-deriv`. The output should include this helpful information. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9444 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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

#9444: -ddump-deriv doesn't dump failed newtype-deriving -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: invalid | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by goldfire): * status: new => closed * resolution: => invalid Comment: Never mind -- closing this ticket. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9444#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9444: -ddump-deriv doesn't dump failed newtype-deriving -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: invalid | Keywords: deriving Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * keywords: => deriving -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9444#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC