invertible-0.2.0.8: bidirectional arrows, bijective functions, and invariant functors
Safe HaskellTrustworthy
LanguageHaskell2010

Data.Invertible.Bijection

Description

The base representation for bidirectional arrows (bijections).

Synopsis

Documentation

data Bijection (a :: * -> * -> *) b c Source #

A representation of a bidirectional arrow (embedding-projection pair of arrows transformer): an arrow and its inverse. Most uses will prefer the specialized <-> type for function arrows.

To constitute a valid bijection, biTo and biFrom should be inverses:

  • biTo . biFrom = id
  • biFrom . biTo = id

It may be argued that the arguments should be in the opposite order due to the arrow syntax, but it makes more sense to me to have the forward function come first.

Constructors

(:<->:) infix 2 

Fields

Instances

Instances details
Category a => Category (Bijection a :: Type -> Type -> Type) Source # 
Instance details

Defined in Data.Invertible.Bijection

Methods

id :: forall (a0 :: k). Bijection a a0 a0 #

(.) :: forall (b :: k) (c :: k) (a0 :: k). Bijection a b c -> Bijection a a0 b -> Bijection a a0 c #

Semigroupoid a => Groupoid (Bijection a :: Type -> Type -> Type) Source # 
Instance details

Defined in Data.Invertible.Bijection

Methods

inv :: forall (a0 :: k) (b :: k). Bijection a a0 b -> Bijection a b a0 Source #

Semigroupoid a => Semigroupoid (Bijection a :: Type -> Type -> Type) Source # 
Instance details

Defined in Data.Invertible.Bijection

Methods

o :: forall (j :: k) (k1 :: k) (i :: k). Bijection a j k1 -> Bijection a i j -> Bijection a i k1 Source #

Arrow a => Arrow (Bijection a) Source #

In order to use all the Arrow functions, we make a partially broken instance, where arr creates a bijection with a broken biFrom. See note on BiArrow'. &&& is first-biased, and uses only the left argument's biFrom.

Instance details

Defined in Data.Invertible.Bijection

Methods

arr :: (b -> c) -> Bijection a b c #

first :: Bijection a b c -> Bijection a (b, d) (c, d) #

second :: Bijection a b c -> Bijection a (d, b) (d, c) #

(***) :: Bijection a b c -> Bijection a b' c' -> Bijection a (b, b') (c, c') #

(&&&) :: Bijection a b c -> Bijection a b c' -> Bijection a b (c, c') #

ArrowChoice a => ArrowChoice (Bijection a) Source #

||| is Left-biased, and uses only the left argument's biFrom.

Instance details

Defined in Data.Invertible.Bijection

Methods

left :: Bijection a b c -> Bijection a (Either b d) (Either c d) #

right :: Bijection a b c -> Bijection a (Either d b) (Either d c) #

(+++) :: Bijection a b c -> Bijection a b' c' -> Bijection a (Either b b') (Either c c') #

(|||) :: Bijection a b d -> Bijection a c d -> Bijection a (Either b c) d #

ArrowZero a => ArrowZero (Bijection a) Source # 
Instance details

Defined in Data.Invertible.Bijection

Methods

zeroArrow :: Bijection a b c #

Invariant2 (Bijection (->)) Source # 
Instance details

Defined in Data.Invertible.Bijection

Methods

invmap2 :: (a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> Bijection (->) a b -> Bijection (->) c d Source #

(Semigroupoid a, Arrow a) => BiArrow (Bijection a) Source # 
Instance details

Defined in Control.Invertible.BiArrow

Methods

(<->) :: (b -> c) -> (c -> b) -> Bijection a b c Source #

invert :: Bijection a b c -> Bijection a c b Source #

(Semigroupoid a, Arrow a) => BiArrow' (Bijection a) Source # 
Instance details

Defined in Control.Invertible.BiArrow

Monad m => Arrow (MonadArrow (<->) m) Source # 
Instance details

Defined in Control.Invertible.MonadArrow

Methods

arr :: (b -> c) -> MonadArrow (<->) m b c #

first :: MonadArrow (<->) m b c -> MonadArrow (<->) m (b, d) (c, d) #

second :: MonadArrow (<->) m b c -> MonadArrow (<->) m (d, b) (d, c) #

(***) :: MonadArrow (<->) m b c -> MonadArrow (<->) m b' c' -> MonadArrow (<->) m (b, b') (c, c') #

(&&&) :: MonadArrow (<->) m b c -> MonadArrow (<->) m b c' -> MonadArrow (<->) m b (c, c') #

Monad m => ArrowChoice (MonadArrow (<->) m) Source # 
Instance details

Defined in Control.Invertible.MonadArrow

Methods

left :: MonadArrow (<->) m b c -> MonadArrow (<->) m (Either b d) (Either c d) #

right :: MonadArrow (<->) m b c -> MonadArrow (<->) m (Either d b) (Either d c) #

(+++) :: MonadArrow (<->) m b c -> MonadArrow (<->) m b' c' -> MonadArrow (<->) m (Either b b') (Either c c') #

(|||) :: MonadArrow (<->) m b d -> MonadArrow (<->) m c d -> MonadArrow (<->) m (Either b c) d #

MonadPlus m => ArrowPlus (MonadArrow (<->) m) Source # 
Instance details

Defined in Control.Invertible.MonadArrow

Methods

(<+>) :: MonadArrow (<->) m b c -> MonadArrow (<->) m b c -> MonadArrow (<->) m b c #

MonadPlus m => ArrowZero (MonadArrow (<->) m) Source # 
Instance details

Defined in Control.Invertible.MonadArrow

Methods

zeroArrow :: MonadArrow (<->) m b c #

Invariant (Bijection (->) b) Source # 
Instance details

Defined in Data.Invertible.Bijection

Methods

invmap :: (a -> b0) -> (b0 -> a) -> Bijection (->) b a -> Bijection (->) b b0 Source #

Monad m => BiArrow' (MonadArrow (<->) m) Source # 
Instance details

Defined in Control.Invertible.MonadArrow

(Semigroupoid a, Arrow a) => Functor (Bijection a b) Source # 
Instance details

Defined in Control.Invertible.Functor

Methods

fmap :: (a0 <-> b0) -> Bijection a b a0 -> Bijection a b b0 Source #

Monoidal (Bijection (->) ()) Source # 
Instance details

Defined in Control.Invertible.Monoidal

Methods

unit :: Bijection (->) () () Source #

(>*<) :: Bijection (->) () a -> Bijection (->) () b -> Bijection (->) () (a, b) Source #

type (<->) = Bijection (->) infix 2 Source #

Specialization of Bijection to function arrows. Represents both a function, f, and its (presumed) inverse, g, represented as f :<->: g.