Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
A pseudo-inverse category is a category where every morphism has a pseudo-inverse.
Synopsis
- class Category a => ToHask a where
- piapply :: a x y -> x -> y
- class Category a => HasHaskFunctors a where
- class Category a => PseudoInverseCategory a where
- class PseudoInverseCategory a => PIArrow a where
- piswap :: PIArrow a => a (b, c) (c, b)
- piassoc :: PIArrow a => a ((b, c), d) (b, (c, d))
- data EndoIso a b = EndoIso (a -> a) (a -> b) (b -> a)
- pimap :: Functor EndoIso EndoIso f => EndoIso a b -> f a -> f b
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
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
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
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
.
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
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 # | |
Defined in Control.PseudoInverseCategory 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
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.
EndoIso (a -> a) (a -> b) (b -> a) |
Instances
PIArrow EndoIso Source # | |
Defined in Control.PseudoInverseCategory 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 # | |
HasHaskFunctors EndoIso Source # | |
ToHask EndoIso Source # | |
Defined in Control.PseudoInverseCategory | |
Category EndoIso Source # | |
Applicative m => Functor EndoIso EndoIso (Continuation m :: Type -> Type) Source # |
|
Defined in Shpadoinkle.Continuation map :: 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. |
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. |
Applicative m => Functor EndoIso EndoIso (Html m :: Type -> Type) Source # |
|
Functor EndoIso ((->) :: Type -> Type -> Type) Identity Source # | |