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

Safe HaskellNone
LanguageHaskell2010

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
ToHask EndoIso Source # 
Instance details

Defined in Control.PseudoInverseCategory

Methods

piapply :: 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
HasHaskFunctors EndoIso Source # 
Instance details

Defined in Control.PseudoInverseCategory

Methods

fmapA :: 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
PseudoInverseCategory EndoIso Source # 
Instance details

Defined in Control.PseudoInverseCategory

Methods

pipower :: 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
PIArrow EndoIso Source # 
Instance details

Defined in Control.PseudoInverseCategory

Methods

piiso :: (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
PIArrow EndoIso Source # 
Instance details

Defined in Control.PseudoInverseCategory

Methods

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

PseudoInverseCategory EndoIso Source # 
Instance details

Defined in Control.PseudoInverseCategory

Methods

pipower :: 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 #

HasHaskFunctors EndoIso Source # 
Instance details

Defined in Control.PseudoInverseCategory

Methods

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

ToHask EndoIso Source # 
Instance details

Defined in Control.PseudoInverseCategory

Methods

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

Category EndoIso Source # 
Instance details

Defined in Control.PseudoInverseCategory

Methods

id :: EndoIso a a #

(.) :: EndoIso b c -> EndoIso a b -> EndoIso a c #

Applicative m => Functor EndoIso EndoIso (Continuation m :: Type -> Type) Source #

Continuation m is a Functor in the EndoIso category (where the objects are types and the morphisms are EndoIsos).

Instance details

Defined in Shpadoinkle.Continuation

Methods

map :: EndoIso a b -> EndoIso (Continuation m a) (Continuation m b) #

Monad 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 details

Defined in Shpadoinkle.Core

Methods

map :: EndoIso a b -> EndoIso (Prop m a) (Prop m b) #

Monad 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 details

Defined in Shpadoinkle.Core

Methods

map :: EndoIso a b -> EndoIso (Html m a) (Html m b) #

Functor EndoIso ((->) :: Type -> Type -> Type) Identity Source # 
Instance details

Defined in Control.PseudoInverseCategory

Methods

map :: EndoIso a b -> Identity a -> Identity b #

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