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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

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

GHC - devs mailing list
#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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

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

GHC - devs mailing list
#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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

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

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

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

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

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

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets