[GHC] #14333: GHC doesn't use the fact that Coercible is symmetric

GHC ghc-devs at haskell.org
Sun Oct 8 13:58:30 UTC 2017


#14333: GHC doesn't use the fact that Coercible is symmetric
-------------------------------------+-------------------------------------
           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
 {-# Language ScopedTypeVariables, GADTs, DeriveGeneric #-}

 import GHC.Generics
 import Data.Type.Coercion

 data AB = A | B deriving (Generic)
 data XY = X | Y deriving (Generic)

 data This ab xy where
   At :: This AB XY

 foo :: This ab xy -> Coercion (Rep ab a) (Rep xy a)
 foo At = Coercion

 bar :: forall ab xy a. This ab xy -> Coercion (Rep ab a) (Rep xy a)
 bar at
   | Coercion <- foo at :: Coercion (Rep ab a) (Rep xy a)
   = Coercion
 }}}

 This compiles on 8.2.1 and 8.3.20170920 but flipping the arguments to
 `Coercion` fails

 {{{#!hs
 -- ...

 -- • Could not deduce: Coercible (Rep xy a) (Rep ab a)
 --     arising from a use of ‘Coercion’
 --   from the context: Coercible (Rep ab a) (Rep xy a)
 --     bound by a pattern with constructor:

 bar :: forall ab xy a. This ab xy -> Coercion (Rep xy a) (Rep ab a)
 bar at
   | Coercion <- foo at :: Coercion (Rep ab a) (Rep xy a)
   = Coercion
 }}}

 Conceptually there should be an (`Undecidable`) superclass constraint for
 `Coercible`

 {{{#!hs
 class Coercible b a => Coercible a b
 }}}

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14333>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list