CATEGORY THEORY
FOR PROGRAMMERS
WHY?
▸ You want to do data modelling (database)
▸ You know Haskell and want to understand it better
▸ You want to be a better programmer
Monoid
! id f g h
Category with one object
Multiple arrows pointing to itself
Functor
a
b
F a
F a
F
F
f fmap
fmap: (a → b) → (F a → F b)
C D
Set
domain of f
domain of g
codomain of f
codomain of g
f ○ g: X → Z
Commutative Diagram
A
C
B
f
g
h
DNA
Amino Acid
RNA
codes for
codes for
codes for
Ologs
TypeType
aspectaspect
Type
A mobile noa name
has
a person
A date of
birth
hashas
(valid aspect) (valid aspect) (invalid aspect)
Because there maybe be 0 or
multiple no’s per person, and no’s
can change too.
Graphs
f
A Graph G := (V, A, src, tgt)
v
u
w
g
V
u
v
w
A src tgt
f u v
g u w
V - A set of vertices
tgt - target function
A - A set of Arrows
src - source function
Database Schema
Name
Person
Date of
Birth
Employee
Mobile No
Manager
Vertices are tables
Arrows are foreign keys
All tables will have an
id column
Manager
is a graph with rules
Department
Rule 1 : Employees and their manager must be in the same department

Category Theory for Programmers