data-category-0.1.0: Restricted categories

Portabilitynon-portable
Stabilityexperimental
Maintainersjoerd@w3future.com

Data.Category

Contents

Description

 

Synopsis

Categories

class CategoryO (~>) a whereSource

An instance CategoryO (~>) a declares a as an object of the category (~>).

Methods

id :: a ~> aSource

(!) :: Nat ~> d f g -> Obj a -> Component f g aSource

Instances

CategoryO (->) a 
CategoryO Unit UnitO 
CategoryO Pair Snd 
CategoryO Pair Fst 
CategoryO Boolean Tru 
CategoryO Boolean Fls 
CategoryO Omega Z 
CategoryO Omega n => CategoryO Omega (S n) 
Monoid m => CategoryO (MonoidA m) m 
(Dom f ~ ~>, Cod f ~ ~>, CategoryO ~> a) => CategoryO (Alg f) (Algebra f a) 
(Dom f ~ Pair, Cod f ~ ~>, CategoryO ~> (F f Fst), CategoryO ~> (F f Snd)) => CategoryO (Nat Pair ~>) f 
(Dom m ~ (->), Cod m ~ (->), Monad m) => CategoryO (Kleisli (->) m) o 

class (CategoryO ~> a, CategoryO ~> b, CategoryO ~> c) => CategoryA (~>) a b c whereSource

An instance CategoryA (~>) a b c defines composition of the arrows a ~> b and b ~> c.

Methods

(.) :: (b ~> c) -> (a ~> b) -> a ~> cSource

Instances

CategoryA (->) a b c 
CategoryA Unit UnitO UnitO UnitO 
CategoryA Pair Snd Snd Snd 
CategoryA Pair Fst Fst Fst 
CategoryA Boolean Tru Tru Tru 
CategoryA Boolean Fls Tru Tru 
CategoryA Boolean Fls Fls Tru 
CategoryA Boolean Fls Fls Fls 
CategoryO Omega n => CategoryA Omega Z Z n 
CategoryA Omega Z n p => CategoryA Omega Z (S n) (S p) 
CategoryA Omega n p q => CategoryA Omega (S n) (S p) (S q) 
Monoid m => CategoryA (MonoidA m) m m m 
(Dom f ~ ~>, Cod f ~ ~>, CategoryA ~> a b c) => CategoryA (Alg f) (Algebra f a) (Algebra f b) (Algebra f c) 
(Dom m ~ (->), Cod m ~ (->), Monad m, FunctorA m b (F m c)) => CategoryA (Kleisli (->) m) a b c 

class (CategoryO ~> a, CategoryO ~> b) => Apply (~>) a b whereSource

Methods

($$) :: (a ~> b) -> a -> bSource

type Obj a = aSource

The type synonym Obj a, when used as the type of a function argument, is a promise that the value of the argument is not used, and only the type. This is used to pass objects (which are types) to functions.

obj :: Obj aSource

obj is a synonym for undefined. When you need to pass an object to a function, you can use (obj :: type).

Functors

type family F ftag a :: *Source

Functors are represented by a type tag. The type family F turns the tag into the actual functor.

type family Dom ftag :: * -> * -> *Source

The domain, or source category, of the functor.

type family Cod ftag :: * -> * -> *Source

The codomain, or target category, of the funcor.

class (CategoryO (Dom ftag) a, CategoryO (Dom ftag) b) => FunctorA ftag a b whereSource

The mapping of arrows by covariant functors. To make this type check, we need to pass the type tag along.

Methods

(%) :: Obj ftag -> Dom ftag a b -> Cod ftag (F ftag a) (F ftag b)Source

Instances

(Dom f ~ Pair, Cod f ~ (->), Dom g ~ Pair, Cod g ~ (->)) => FunctorA CoprodInHask f g 
(Dom f ~ Pair, Cod f ~ (->), Dom g ~ Pair, Cod g ~ (->)) => FunctorA ProdInHask f g 
(CategoryO ~> a, CategoryO ~> b) => FunctorA (Id ~>) a b 
Functor f => FunctorA (EndoHask f) a b 
(CategoryO ~> a, CategoryO ~> b, CategoryA ~> x a b) => FunctorA (:*-: x ~>) a b 
(Cod h ~ Dom g, FunctorA g (F h a) (F h b), FunctorA h a b) => FunctorA (:.: g h) a b 
(CategoryO ~> a, CategoryO ~> b) => FunctorA (Diag (->) ~>) a b 
(CategoryO ~> a, CategoryO ~> b) => FunctorA (Diag Void ~>) a b 
(CategoryO ~> a, CategoryO ~> b) => FunctorA (Diag Pair ~>) a b 
(Dom m ~ (->), Cod m ~ (->), Monad m, FunctorA m a (F m b)) => FunctorA (KleisliAdjG (->) m) a b 
(Dom m ~ (->), Cod m ~ (->), Monad m) => FunctorA (KleisliAdjF (->) m) a b 
(CategoryO c1 a, CategoryO c1 b, CategoryO c2 x) => FunctorA (Const c1 c2 x) a b 
CategoryO ~> y => FunctorA (PairF ~> x y) Snd Snd 
CategoryO ~> x => FunctorA (PairF ~> x y) Fst Fst 
CategoryO ~> z => FunctorA (OmegaF ~> z f) Z Z 

class (CategoryO (Dom ftag) a, CategoryO (Dom ftag) b) => ContraFunctorA ftag a b whereSource

The mapping of arrows by contravariant functors.

Methods

(-%) :: Obj ftag -> Dom ftag a b -> Cod ftag (F ftag b) (F ftag a)Source

Instances

(CategoryO ~> a, CategoryO ~> b, CategoryA ~> a b x) => ContraFunctorA (:-*: ~> x) a b 

Functor instances

data Id (~>) Source

The identity functor on (~>)

Constructors

Id 

Instances

(CategoryO ~> a, CategoryO ~> b) => FunctorA (Id ~>) a b 

data g :.: h Source

The composition of two functors.

Constructors

g :.: h 

Instances

(Dom m ~ (->), Cod m ~ (->), Pointed m) => Pointed (:.: (KleisliAdjG (->) m) (KleisliAdjF (->) m)) 
(Cod h ~ Dom g, FunctorA g (F h a) (F h b), FunctorA h a b) => FunctorA (:.: g h) a b 

data Const c1 c2 x Source

The constant functor.

Constructors

Const 

Instances

(CategoryO c1 a, CategoryO c1 b, CategoryO c2 x) => FunctorA (Const c1 c2 x) a b 

data x :*-: (~>) Source

The covariant functor Hom(X,--)

Constructors

HomX_ 

Instances

(CategoryO ~> a, CategoryO ~> b, CategoryA ~> x a b) => FunctorA (:*-: x ~>) a b 

data (~>) :-*: x Source

The contravariant functor Hom(--,X)

Constructors

Hom_X 

Instances

(CategoryO ~> a, CategoryO ~> b, CategoryA ~> a b x) => ContraFunctorA (:-*: ~> x) a b 

Natural transformations

data family Nat c d f g :: *Source

type :~> f g = (c ~ Dom f, c ~ Dom g, d ~ Cod f, d ~ Cod g) => Nat c d f gSource

f :~> g is a natural transformation from functor f to functor g.

type Component f g z = Cod f (F f z) (F g z)Source

Natural transformations are built up of components, one for each object z in the domain category of f and g. This type synonym can be used when creating data instances of Nat.

Universal arrows

data InitialUniversal x u a Source

Constructors

InitialUniversal (F (InitMorF x u) a) (InitMorF x u :~> (a :*-: Dom u)) 

data TerminalUniversal x u a Source

Constructors

TerminalUniversal (F (TermMorF x u) a) (TermMorF x u :~> (Dom u :-*: a)) 

Adjunctions

data Adjunction f g Source

Constructors

Adjunction 

Fields

unit :: Id (Dom f) :~> (g :.: f)
 
counit :: (f :.: g) :~> Id (Dom g)