{-# LANGUAGE CPP #-}
#if __GLASGOW_HASKELL__ >= 708
#define USE_COERCE
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
#else
{-# LANGUAGE Unsafe #-}
#endif
module Control.Lens.Internal.Coerce
( coerce
, coerce'
, (#..)
) where
import Data.Profunctor.Unsafe
#ifdef USE_COERCE
import Data.Coerce
coerce' :: forall a b. Coercible a b => b -> a
coerce' :: b -> a
coerce' = (a -> a) -> b -> a
forall a b. Coercible a b => a -> b
coerce (a -> a
forall a. a -> a
id :: a -> a)
{-# INLINE coerce' #-}
(#..) :: (Profunctor p, Coercible c b) => (b -> c) -> p a b -> p a c
#.. :: (b -> c) -> p a b -> p a c
(#..) = (b -> c) -> p a b -> p a c
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
(#.)
{-# INLINE (#..) #-}
#else
import Unsafe.Coerce
coerce, coerce' :: a -> b
coerce = unsafeCoerce
coerce' = unsafeCoerce
{-# INLINE coerce #-}
{-# INLINE coerce' #-}
(#..) :: Profunctor p => (b -> c) -> p a b -> p a c
(#..) = (#.)
{-# INLINE (#..) #-}
#endif