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

GHC ghc-devs at haskell.org
Sat Mar 14 03:26:54 UTC 2015


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

Comment (by glguy):

 The feature request is that coerce' should not be necessary

 {{{
 {-# LANGUAGE ScopedTypeVariables #-}
 module FeatureRequest where

 import Data.Coerce

 data Iso a b = Iso (a -> b) (b -> a)

 -- coerceIso :: Coercible a b => Iso a b -- desired
 coerceIso :: (Coercible a b, Coercible b a) => Iso a b -- required
 coerceIso = Iso coerce coerce

 coerce' :: forall a b. Coercible a b => b -> a
 coerce' = coerce (id :: a -> a)

 coerceIso' :: Coercible a b => Iso a b -- work around
 coerceIso' = Iso coerce coerce'
 }}}

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


More information about the ghc-tickets mailing list