invertible-0.2.0.6: 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
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') #

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

Defined in Data.Invertible.Bijection

Methods

zeroArrow :: Bijection a b 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 #

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

Defined in Data.Invertible.Bijection

Methods

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

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

Defined in Control.Invertible.BiArrow

(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 #

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

Defined in Data.Invertible.Bijection

Methods

id :: Bijection a a0 a0 #

(.) :: 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 :: Bijection a a0 b -> Bijection a b a0 #

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

Defined in Data.Invertible.Bijection

Methods

o :: Bijection a j k1 -> Bijection a i j -> Bijection a i k1 #

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') #

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

Defined in Control.Invertible.MonadArrow

Methods

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

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 #

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 #

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

Defined in Data.Invertible.Bijection

Methods

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

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 ((->) :: Type -> Type -> Type) ()) 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.