{-# LANGUAGE Safe #-}
module Data.Invertible.Internal
  ( invert
  , involution
  ) where

import Data.Invertible.Bijection

-- |Invert an isomorphism by exchanging the two arrows (same as 'Control.Invertible.BiArrow.invert').
invert :: Bijection a b c -> Bijection a c b
invert :: forall (a :: * -> * -> *) b c. Bijection a b c -> Bijection a c b
invert (a b c
f :<->: a c b
g) = a c b
g forall (a :: * -> * -> *) b c. a b c -> a c b -> Bijection a b c
:<->: a b c
f
{-# INLINE invert #-}

-- |Construct an involution (an bijection where the function and inverse are the same) (overlaps with 'Control.Invertible.BiArrow.involve').
involution :: a b b -> Bijection a b b
involution :: forall (a :: * -> * -> *) b. a b b -> Bijection a b b
involution a b b
f = a b b
f forall (a :: * -> * -> *) b c. a b c -> a c b -> Bijection a b c
:<->: a b b
f
{-# INLINE involution #-}