[GHC] #10156: Unable to coerce with flipped Coercible context

GHC ghc-devs at haskell.org
Fri Mar 13 19:22:25 UTC 2015


#10156: Unable to coerce with flipped Coercible context
-------------------------------------+-------------------------------------
              Reporter:  ekmett      |             Owner:
                  Type:  feature     |            Status:  new
  request                            |         Milestone:
              Priority:  normal      |           Version:  7.10.1-rc2
             Component:  Compiler    |  Operating System:  Unknown/Multiple
  (Type checker)                     |   Type of failure:  None/Unknown
              Keywords:              |        Blocked By:
          Architecture:              |   Related Tickets:
  Unknown/Multiple                   |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------
 {{{#!hs
 coerce' :: Coercible a b => b -> a
 coerce' = coerce
 }}}

 doesn't compile, forcing workarounds like:

 {{{#!hs
 coerce' :: forall a b. Coercible a b => b -> a
 coerce' = coerce (id :: a -> a)
 }}}

 This arises in practice in several places in the `profunctors` package and
 `lens`.

 https://github.com/ekmett/profunctors/blob/1c3508e5274a0ed03765c569596a8fda8817ed56/src/Data/Profunctor/Unsafe.hs#L188

 http://hackage.haskell.org/package/lens-4.8/docs/src/Control-Lens-
 Internal-Coerce.html#coerce%27

 Ideally we'd be able to retire `coerce'` entirely and just use `coerce` in
 those contexts.

 The tricky part is of course avoiding infinite loops once you add
 symmetry.

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


More information about the ghc-tickets mailing list