Shpadoinkle-0.3.1.0: A programming model for declarative, high performance user interface.

Control.PseudoInverseCategory

Contents

Description

A pseudo-inverse category is a category where every morphism has a pseudo-inverse.

Synopsis

# Classes

class Category a => ToHask a where Source #

A type satisfying this class is a functor from another category to Hask. Laws:

piapply (f . g) = piapply f . piapply g
piapply id = id

Methods

piapply :: a x y -> x -> y Source #

#### Instances

Instances details
 Source # Instance detailsDefined in Control.PseudoInverseCategory Methodspiapply :: EndoIso x y -> x -> y Source #

class Category a => HasHaskFunctors a where Source #

For any type a satisfying this class, we can lift endofunctors of Hask into a. This mapping should constitute a functor from one monoidal category of endofunctors to the other. That statement defines the applicable laws, which are, in other words:

fmapA id = id
fmapA (f >>> g) = fmapA f >>> fmapA g

Methods

fmapA :: Functor f => a x y -> a (f x) (f y) Source #

#### Instances

Instances details
 Source # Instance detailsDefined in Control.PseudoInverseCategory MethodsfmapA :: Functor f => EndoIso x y -> EndoIso (f x) (f y) Source #

class Category a => PseudoInverseCategory a where Source #

A pseudo-inverse category is a category where every morphism has a pseudo-inverse. What this means is defined by the following laws (perhaps things can be removed and perhaps things should be added):

pipower 1 f = f
pileft (pipower 0 f) = id
piright (pipower 0 f) = id
pipower (n+1) f = pileft f . pipower n f
piinverse (piinverse f) = f
f . piinverse f = piright (pipower 2 f)
piinverse f . f = pileft (pipower 2 f)
pileft (piright f) = piright (piright f) = piright f
piright (pileft f) = pileft (pileft f) = pileft f
piinverse (pileft f) = pileft f
piinverse (piright f) = piright f

Methods

pipower :: Int -> a x y -> a x y Source #

Apply a morphism n times, n >= 0.

pileft :: a x y -> a x x Source #

Change a morphism into an endomorphism of its domain.

piright :: a x y -> a y y Source #

Change a morphism into an endomorphism of its codomain.

piinverse :: a x y -> a y x Source #

Pseudo-invert a morphism. The pseudo-inverse of a morphism may or may not be its inverse. f is the inverse of g means that f.g = id = g.f. If f has an inverse, then piinverse f may or may not be the inverse of f.

#### Instances

Instances details
 Source # Instance detailsDefined in Control.PseudoInverseCategory Methodspipower :: Int -> EndoIso x y -> EndoIso x y Source #pileft :: EndoIso x y -> EndoIso x x Source #piright :: EndoIso x y -> EndoIso y y Source #piinverse :: EndoIso x y -> EndoIso y x Source #

class PseudoInverseCategory a => PIArrow a where Source #

An analogue of the Arrow typeclass for pseudo-inverse categories. Laws:

piiso id id = id
piendo id = id
piiso (f . g) (h . i) = piiso f h . piiso g i
piendo (f . h) = piendo f . piendo h
pifirst (piiso f g) = piiso (first f) (first g)
pifirst (piendo f) = piendo (first f)
pifirst (f . g) = pifirst f . pifirst g
pisplit id g . pifirst f = pifirst f . pisplit id g
piassoc . first (first f) = first f . piassoc
pisecond f = piswap . pifirst f . piswap
pisplit f g = pifirst f . pisecond g
pifan f g = piiso (\b -> (b,b)) fst . pisplit f g
piinverse (piiso f g) = piiso g f
piinverse (piendo f) = piendo f
piapply (piiso f g) = f
piapply (piinverse (piiso f g)) = g
piapply (piendo f) = f

Methods

piiso :: (b -> c) -> (c -> b) -> a b c Source #

Create an arrow from an isomorphism (restricted version of arr).

piendo :: (b -> b) -> a b b Source #

Create an arrow from an endomorphism (restricted version of arr).

pifirst :: a b c -> a (b, d) (c, d) Source #

Apply an arrow to the first coordinate of a tuple.

pisecond :: a b c -> a (d, b) (d, c) Source #

Apply an arrow to the second coordinate of a tuple.

pisplit :: a b c -> a d e -> a (b, d) (c, e) Source #

Combine two arrows to work in parallel on a tuple.

pifan :: a b c -> a b d -> a b (c, d) Source #

Combine two arrows on the same input to output a tuple.

#### Instances

Instances details
 Source # Instance detailsDefined in Control.PseudoInverseCategory Methodspiiso :: (b -> c) -> (c -> b) -> EndoIso b c Source #piendo :: (b -> b) -> EndoIso b b Source #pifirst :: EndoIso b c -> EndoIso (b, d) (c, d) Source #pisecond :: EndoIso b c -> EndoIso (d, b) (d, c) Source #pisplit :: EndoIso b c -> EndoIso d e -> EndoIso (b, d) (c, e) Source #pifan :: EndoIso b c -> EndoIso b d -> EndoIso b (c, d) Source #

piswap :: PIArrow a => a (b, c) (c, b) Source #

Every pseudo-inverse category has isomorphisms to swap the coordinates of a tuple.

piassoc :: PIArrow a => a ((b, c), d) (b, (c, d)) Source #

Every pseudo-inverse category has isomorphisms to change the associativity of a 3-tuple.

# EndoIso

data EndoIso a b Source #

This is a pseudo-inverse category where a morphism is a composition of an endomorphism on the domain and an isomorphism of the domain with the codomain. The last two arguments are required to form an isomorphism, i.e. for all EndoIso f g h:

g . h = id
h . g = id

This category contains as objects all types in Hask and as morphisms all compositions of endomorphisms and isomorphisms in Hask.

Constructors

 EndoIso (a -> a) (a -> b) (b -> a)

#### Instances

Instances details
 Source # Instance detailsDefined in Control.PseudoInverseCategory Methodspiiso :: (b -> c) -> (c -> b) -> EndoIso b c Source #piendo :: (b -> b) -> EndoIso b b Source #pifirst :: EndoIso b c -> EndoIso (b, d) (c, d) Source #pisecond :: EndoIso b c -> EndoIso (d, b) (d, c) Source #pisplit :: EndoIso b c -> EndoIso d e -> EndoIso (b, d) (c, e) Source #pifan :: EndoIso b c -> EndoIso b d -> EndoIso b (c, d) Source # Source # Instance detailsDefined in Control.PseudoInverseCategory Methodspipower :: Int -> EndoIso x y -> EndoIso x y Source #pileft :: EndoIso x y -> EndoIso x x Source #piright :: EndoIso x y -> EndoIso y y Source #piinverse :: EndoIso x y -> EndoIso y x Source # Source # Instance detailsDefined in Control.PseudoInverseCategory MethodsfmapA :: Functor f => EndoIso x y -> EndoIso (f x) (f y) Source # Source # Instance detailsDefined in Control.PseudoInverseCategory Methodspiapply :: EndoIso x y -> x -> y Source # Source # Instance detailsDefined in Control.PseudoInverseCategory Methodsid :: forall (a :: k). EndoIso a a #(.) :: forall (b :: k) (c :: k) (a :: k). EndoIso b c -> EndoIso a b -> EndoIso a c # Source # Continuation m is a Functor in the EndoIso category (where the objects are types and the morphisms are EndoIsos). Instance detailsDefined in Shpadoinkle.Continuation Methodsmap :: forall (a :: α) (b :: α). EndoIso a b -> EndoIso (Continuation m a) (Continuation m b) # Applicative m => Functor EndoIso EndoIso (Props m :: Type -> Type) Source # Props is a functor in the EndoIso category, where the objects are types and the morphisms are EndoIsos. Instance detailsDefined in Shpadoinkle.Core Methodsmap :: forall (a :: α) (b :: α). EndoIso a b -> EndoIso (Props m a) (Props m b) # Applicative m => Functor EndoIso EndoIso (Prop m :: Type -> Type) Source # Prop is a functor in the EndoIso category, where the objects are types and the morphisms are EndoIsos. Instance detailsDefined in Shpadoinkle.Core Methodsmap :: forall (a :: α) (b :: α). EndoIso a b -> EndoIso (Prop m a) (Prop m b) # Applicative m => Functor EndoIso EndoIso (Html m :: Type -> Type) Source # Html m is a functor in the EndoIso category, where the objects are types and the morphisms are EndoIsos. Instance detailsDefined in Shpadoinkle.Core Methodsmap :: forall (a :: α) (b :: α). EndoIso a b -> EndoIso (Html m a) (Html m b) # Functor EndoIso ((->) :: Type -> Type -> Type) Identity Source # Instance detailsDefined in Control.PseudoInverseCategory Methodsmap :: forall (a :: α) (b :: α). EndoIso a b -> Identity a -> Identity b #

pimap :: Functor EndoIso EndoIso f => EndoIso a b -> f a -> f b Source #