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

GHC ghc-devs at haskell.org
Mon Oct 9 19:06:41 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
      Resolution:                    |             Keywords:  TypeFamilies,
                                     |  Roles
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):

 Could you include the full code of the concrete use case? I followed the
 link, but that's a non-trivial and not-self-contained file.

 GHC accepts

 {{{#!hs
 f :: Coercible b a => a x -> b x
 f = coerce
 }}}

 So, if `SameRep a b` implies `Coercible (Rep a) (Rep b)`, then the final
 implication above should hold. If, on the other hand, `SameRep a b`
 implies `forall x. Coercible (Rep a x) (Rep b x)`, then you're in trouble
 (at least with the current implementation).

 It occurs to me that you do not necessarily need to do anything clever
 with `a b ~R# c d`, but instead `F a b ~R# F c d`, where `F` has an arity
 of 1. Tackling the special case where we have a type function at the head,
 instead of any variable, might be easier than the general case.

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


More information about the ghc-tickets mailing list