[GHC] #14247: Fails to coerce between newtypes directly

#14247: Fails to coerce between newtypes directly -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.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: -------------------------------------+------------------------------------- {{{#!hs import Data.Coerce import Data.Type.Coercion newtype W a = W a newtype A = MkA (W A) a :: Coercion A A a = Coercion b :: Coercion a a' -> Coercion a (W a') b Coercion = Coercion c :: Coercion A (W A) c = b a }}} works just fine but the following fail: {{{#!hs -- • Couldn't match representation of type ‘A’ with that of ‘W A’ -- arising from a use of ‘Coercion’ -- • In the expression: Coercion -- In an equation for ‘d’: d = Coercion d :: Coercion A (W A) d = Coercion -- • Couldn't match representation of type ‘A’ with that of ‘W A’ -- arising from a use of ‘coerce’ -- • In the expression: coerce -- In an equation for ‘e’: e = coerce e :: A -> W A e = coerce }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14247 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14247: Fails to coerce between newtypes directly -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): The `Coercible` solver is incomplete when recursive newtypes come into play. We admit this in the JFP paper. I don't know how to do better. And I'm pretty sure the problem is undecidable, anyway. Did this come up in the wild? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14247#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14247: Fails to coerce between newtypes directly -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Iceland_jack): It's artificial and follows from me discussing "deriving via a `newtype`" with Ryan; we wondered if there could be a way to derive via a regular `data` type.. which lead me to something like {{{#!hs newtype W a = W a data A = MkA (W A) }}} where coercing `coerce :: A -> W A` actually works: make `A` a `newtype` and it stops working. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14247#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14247: Fails to coerce between newtypes directly -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: 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 Iceland_jack): * cc: RyanGlScott (added) Comment: For what it's worth, this is the only time I've had issue with the `Coercible` solver! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14247#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14247: Fails to coerce between newtypes directly -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): It's quite amusing to see how one can work around the issue in the first example by manually wrapping `W` a single time using `b`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14247#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14247: Fails to coerce between newtypes directly -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: duplicate | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #10184 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => closed * resolution: => duplicate * related: => #10184 Comment: Closing as a duplicate of #10184. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14247#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC