→ General stuff

→ Set

→ Category Theory in Programming

→ The Empty Set

→ The Singleton Set

→ The two-element Set

→ Hask

→ Set

→ Category Theory in Programming

→ The Empty Set

→ The Singleton Set

→ The two-element Set

→ Hask

These are my lecture notes on Bartosz Milewski's course on category theory. These are not meant as a comprehensive guide but rather a loose collection of definitions and short summaries.

A category has two properties:

Morphisms between any two objects form a set called the

A morphism \(f: a \rightarrow b\) is called

- an
**epimorphism**(or**epic**) if it is right-cancellable, i.e. \(g_1 \circ f = g_2 \circ f\) implies \(g_1 = g_2\) for all \(c\) and all \(g_1, g_2: b \rightarrow c\) - a
**monomorphism**(or**monic**) if it is left-cancellable, i.e. \(f \circ g_1 = f \circ g_2\) implies \(g_1 = g_2\) for all \(c\) and all \(g_1, g_2: c \rightarrow a\) - a
**bimorphism**if it is both a monomorphism and an epimorphism - An
**isomorphism**if it has an inverse, i.e. if there exists an morphism \(f^{-1}: b \rightarrow a\) with \(f^{-1} \circ f = id_a\) and \(f \circ f^{-1} = id_b\).

In

Also notice the distinction between isomorphisms and bimorphisms. While in set theory a function that is bijective (both injective and surjective) is invertible, in category theory a bimorphism (which is both epic and monic) is not necessarily invertible (an isomorphism).

- Boolean represents the set \( \{True, False\}\)
- Int represents a subset of \(\mathbb{N}\)
- Float/Double represents a subset of \(\mathbb{Q}\)

We can define the following (uncallable) functions with Void in Haskell:

```
absurd :: Void → a
id_void :: Void → Void
```

`()`

and we can build the `unit`

function with it:`unit :: a → ()`

Furthermore we can define infinitely many functions of type

`() → a`

. These individual functions are constant. In this way we can express elements of a set as functions, or in category theory as morphisms.For example for type bool we can define the functions

```
true :: () → Bool
true _ = True
false :: () → Bool
false _ = False
```

Such an object

`()`

that allows us to view individual elements of a set as morphisms does not exist for every category. In general, category theory abstracts over elements and looks at sets, functions and other things from a higher perspective.Sidenote: There is an important difference between pure functions in programming and mathematical functions. Mathematical functions instantly evaluate to a certain result while functions in programming may not terminate. To avoid this issue a special element called