[GHC] #14220: GeneralizedNewtypeDeriving and polymorphic arguments don't play nicely together

#14220: GeneralizedNewtypeDeriving and polymorphic arguments don't play nicely together --------------------------------------+--------------------------------- Reporter: ivanm | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Keywords: | Operating System: MacOS X Architecture: x86_64 (amd64) | Type of failure: None/Unknown Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: --------------------------------------+--------------------------------- I'm not sure if this is a bug per se, but ghci says to report it so here it is: test.hs: {{{#!hs {-# LANGUAGE GeneralizedNewtypeDeriving #-} class NameOf a where nameOf :: proxy a -> String instance NameOf Int where nameOf _ = "Int" newtype MyInt = MyInt Int deriving (NameOf) }}} {{{ $ ghci test.hs GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( test.hs, interpreted ) test.hs:10:13: warning: [-Wdeferred-type-errors] • Couldn't match representation of type ‘proxy1 Int’ with that of ‘proxy1 MyInt’ arising from a use of ‘GHC.Prim.coerce’ NB: We cannot know what roles the parameters to ‘proxy1’ have; we must assume that the role is nominal • In the expression: GHC.Prim.coerce @(forall (proxy :: TYPE GHC.Types.PtrRepLifted -> TYPE GHC.Types.PtrRepLifted). proxy Int -> String) @(forall (proxy :: TYPE GHC.Types.PtrRepLifted -> TYPE GHC.Types.PtrRepLifted). proxy MyInt -> String) nameOf In an equation for ‘nameOf’: nameOf = GHC.Prim.coerce @(forall (proxy :: TYPE GHC.Types.PtrRepLifted -> TYPE GHC.Types.PtrRepLifted). proxy Int -> String) @(forall (proxy :: TYPE GHC.Types.PtrRepLifted -> TYPE GHC.Types.PtrRepLifted). proxy MyInt -> String) nameOf When typechecking the code for ‘nameOf’ in a derived instance for ‘NameOf MyInt’: To see the code I am typechecking, use -ddump-deriv In the instance declaration for ‘NameOf MyInt’ ghc: panic! (the 'impossible' happened) (GHC version 8.0.2 for x86_64-apple-darwin): opt_univ fell into a hole {a15j} Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14220 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14220: GeneralizedNewtypeDeriving and polymorphic arguments don't play nicely together ---------------------------------+-------------------------------------- Reporter: ivanm | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Comment (by Iceland_jack): Doesn't panic for 8.0.1 {{{ $ ghci -ignore-dot-ghci /tmp/a.hs GHCi, version 7.8.4: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. [1 of 1] Compiling Main ( /tmp/a.hs, interpreted ) /tmp/a.hs:10:13: Could not coerce from ‘proxy Int’ to ‘proxy MyInt’ because ‘proxy Int’ and ‘proxy MyInt’ are different types. arising from the coercion of the method ‘nameOf’ from type ‘forall (proxy :: * -> *). proxy Int -> String’ to type ‘forall (proxy :: * -> *). proxy MyInt -> String’ Possible fix: use a standalone 'deriving instance' declaration, so you can specify the instance context yourself When deriving the instance for (NameOf MyInt) Failed, modules loaded: none. Prelude> }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14220#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14220: GeneralizedNewtypeDeriving and polymorphic arguments don't play nicely together ---------------------------------+-------------------------------------- Reporter: ivanm | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #12104 | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Changes (by RyanGlScott): * related: => #12104 Comment: Thanks for the bug report. Note that this only happens when `-fdefer-type- errors` is on. This is a duplicate of #12104, which has been fixed in GHC 8.2.1. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14220#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14220: GeneralizedNewtypeDeriving and polymorphic arguments don't play nicely together ---------------------------------+-------------------------------------- Reporter: ivanm | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: duplicate | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #12104 | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Changes (by RyanGlScott): * status: new => closed * resolution: => duplicate -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14220#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC