[GHC] #15766: GeneralizedNewtypeDeriving should support classes with ambiguous types

#15766: GeneralizedNewtypeDeriving should support classes with ambiguous types -------------------------------------+------------------------------------- Reporter: reinerp | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 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: -------------------------------------+------------------------------------- The following module has a class with an ambiguous type: {{{#!hs {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} module Ambig where class C a where c :: Int data A = A instance C A where c = 5 newtype B = B A deriving C }}} Thanks to TypeApplications, this typeclass is still usable. However, GeneralizedNewtypeDeriving fails on it: {{{ Ambig.hs:12:26: error: • Ambiguous type variable ‘a0’ arising from a use of ‘c’ prevents the constraint ‘(C a0)’ from being solved. Probable fix: use a type annotation to specify what ‘a0’ should be. These potential instances exist: instance C A -- Defined at Ambig.hs:10:10 instance C B -- Defined at Ambig.hs:12:26 • In the third argument of ‘GHC.Prim.coerce’, namely ‘c’ In the expression: GHC.Prim.coerce @(Int) @(Int) c In an equation for ‘c’: c = GHC.Prim.coerce @(Int) @(Int) c When typechecking the code for ‘c’ in a derived instance for ‘C B’: To see the code I am typechecking, use -ddump-deriv | 12 | newtype B = B A deriving C | }}} It shouldn't. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15766 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15766: GeneralizedNewtypeDeriving should support classes with ambiguous types -------------------------------------+------------------------------------- Reporter: reinerp | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Resolution: duplicate | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #15637 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => closed * resolution: => duplicate * related: => #15637 Comment: Thanks for the bug report. This is a duplicate of #15637, which has been fixed upstream. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15766#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC