-- | -- Bidirectional version of "Data.Coerce". {-# LANGUAGE TypeOperators #-} module Data.Invertible.Coerce ( coerce ) where import qualified Data.Coerce as C import Data.Invertible.Bijection -- |Safely 'C.coerce' between values of types that have the same representation. coerce :: (C.Coercible a b, C.Coercible b a) => a <-> b coerce :: forall a b. (Coercible a b, Coercible b a) => a <-> b coerce = a -> b forall a b. Coercible a b => a -> b C.coerce (a -> b) -> (b -> a) -> Bijection (->) a b forall (a :: * -> * -> *) b c. a b c -> a c b -> Bijection a b c :<->: b -> a forall a b. Coercible a b => a -> b C.coerce