
#13293: ConstrainedClassMethods makes GeneralizedNewtypeDeriving fail -------------------------------------+------------------------------------- Reporter: j.waldmann | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Example: {{{ {-# language GeneralizedNewtypeDeriving #-} {-# language ConstrainedClassMethods #-} instance ToDoc Int where toDoc = undefined newtype P = P Int deriving ( ToDoc ) type Doc = () class ToDoc a where toDoc :: ToDoc a => a -> Doc }}} compile with ghc-8.0.2: {{{ C.hs:6:30: error: • Couldn't match type ‘Int’ with ‘P’ arising from the coercion of the method ‘toDoc’ from type ‘ToDoc Int => Int -> Doc’ to type ‘ToDoc P => P -> Doc’ • When deriving the instance for (ToDoc P) }}} With ghc-8.0.1, it is fine. When I drop the constraint on the method declaration, ghc-8.0.2 compiles the program. This repetition of the class constraint in the method declaration actually came from a copy-paste error, so this issue does not affect my code, but it's still puzzling. Repeating the class constraint should not change the meaning of the program? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13293 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler