Tutorial by Examples

Category theory is a modern mathematical theory and a branch of abstract algebra focused on the nature of connectedness and relation. It is useful for giving solid foundations and common language to many highly reusable programming abstractions. Haskell uses Category theory as inspiration for some o...
A category C consists of: A collection of objects called Obj(C) ; A collection (called Hom(C)) of morphisms between those objects. If a and b are in Obj(C), then a morphism f in Hom(C) is typically denoted f : a -> b, and the collection of all morphism between a and b is denoted hom(a,b) ; A...
Definition of the category The Haskell types along with functions between types form (almost†) a category. We have an identity morphism (function) (id :: a -> a) for every object (type) a; and composition of morphisms ((.) :: (b -> c) -> (a -> b) -> a -> c), which obey category la...
Categorical products In category theory, the product of two objects X, Y is another object Z with two projections: π₁ : Z → X and π₂ : Z → Y; such that any other two morphisms from another object decompose uniquely through those projections. In other words, if there exist f₁ : W → X and f₂ : W →...
Intuition The categorical product of two types A and B should contain the minimal information necessary to contain inside an instance of type A or type B. We can see now that the intuitive coproduct of two types should be Either a b. Other candidates, such as Either a (b,Bool), would contain a part...
A Haskell's Functor allows one to map any type a (an object of Hask) to a type F a and also map a function a -> b (a morphism of Hask) to a function with type F a -> F b. This corresponds to a Category Theory definition in a sense that functor preserves basic category structure. A monoidal ca...

Page 1 of 1