invertible-0.2.0.5: bidirectional arrows, bijective functions, and invariant functors

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 FieldsbiTo :: a b c biFrom :: a c b

Instances

 Category * a => Category * (Bijection a) Source # Methodsid :: cat a a #(.) :: cat b c -> cat a b -> cat a c # Source # Methodsinv :: k1 a b -> k1 b a # Source # Methodso :: c j k1 -> c i j -> c i k1 # 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. Methodsarr :: (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 # MethodszeroArrow :: Bijection a b c # Source # ||| is Left-biased, and uses only the left argument's biFrom. Methodsleft :: 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 # Source # Methodsinvmap2 :: (a -> c) -> (c -> a) -> (b -> d) -> (d -> b) -> Bijection (LiftedRep -> LiftedRep) a b -> Bijection (LiftedRep -> LiftedRep) c d # (Semigroupoid * a, Arrow a) => BiArrow' (Bijection a) Source # (Semigroupoid * a, Arrow a) => BiArrow (Bijection a) Source # Methods(<->) :: (b -> c) -> (c -> b) -> Bijection a b c Source #invert :: Bijection a b c -> Bijection a c b Source # Monad m => Arrow (MonadArrow (<->) m) # Methodsarr :: (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') # # MethodszeroArrow :: MonadArrow (<->) m b c # # Methods(<+>) :: MonadArrow (<->) m b c -> MonadArrow (<->) m b c -> MonadArrow (<->) m b c # # Methodsleft :: 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 ((->) LiftedRep LiftedRep) b) Source # Methodsinvmap :: (a -> b) -> (b -> a) -> Bijection (LiftedRep -> LiftedRep) b a -> Bijection (LiftedRep -> LiftedRep) b b # Monad m => BiArrow' (MonadArrow (<->) m) Source # (Semigroupoid * a, Arrow a) => Functor (Bijection a b) Source # Methodsfmap :: (a <-> b) -> Bijection a b a -> Bijection a b b Source # Monoidal (Bijection ((->) LiftedRep LiftedRep) ()) Source # Methodsunit :: Bijection (LiftedRep -> LiftedRep) () () Source #(>*<) :: Bijection (LiftedRep -> LiftedRep) () a -> Bijection (LiftedRep -> LiftedRep) () b -> Bijection (LiftedRep -> LiftedRep) () (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.