morphism = function = arrow category: objects and arrows source = origin of arrow target = destination of arrow
f :: A -> B
function f requires an input of type A, and returns B
id :: a -> a
id x = x
names of concrete type always start with a capital letter
names of type variables always start with a lowercase letter
a
stands for all types
func :: a -> a
func x = x
function definition:
- name of the function followed by formal parameters
- body of the function follows the equal sign
- no parentheses around argument list
- no commas between arguments
given a morphism from A to B, and another from B to C, then there must be an morphism from A to C
- composition is associative
f :: A -> B
g :: B -> C
h :: C -> D
h . (g . f) = (h . g) . f = h . g . f
- unit of composition, which is a morphism loops from object to itself (unit arrow, or identity arrow), hence if composing any arrow with the involved two objects' unit arrow, it will return the same arrow. For example, for a morphism f between A and B,
f . id_A = f
id_B . f = f
the identity arrow is similar to the following javascript arrow function
a => a
- target object of an arrow, must be the source object of next arrow
- Set is a special category
- can get intuitions from peeking inside its objects, i.e.
- an empty set has no element
- there are special one-element set