# Category Theory 2

### Part II. The Voyage

` ``add(1,1) // 2`

You will know exactly what this does. - associative (can group them in any order)
- commutative (the arguments can come in any order)
- identity (with a 0 argument it returns the the other argument)
- distributive (can use it in any other composition/function (with
`multiply`

for example)

`add`

can use any type of arguments, not just integers (strings, floats, arrays). You have intuitions and laws behind what

`add`

can do and it always holds (does what you think it should do). ### Category Theory

talks about

`compose`

. The above laws apply to it as well. (Same as `add`

).Talks about the

*type signature*`(b -> c)`

meaning a function that takes `b`

and returns `c`

. (this is a Haskell type signature)`compose :: (b -> c) -> (a -> b) -> (a -> c)`

`id :: a -> a`

You need a

*composition*and an*id*function to create a category

The

*identity*function (above, just gives back the same value)### Category Laws

Uses the

`identity`

function (`id`

) below` ````
// left identity
compose(id, f) == f
// rigth identity
compose(f, id) == f
// associativity
compose(compose(f,g), h) == compose(f, compose(g,h))
```

Demoes on jsbin that since `compose`

is associative, he can group the functions in any way he wants (and extract them). Just like `add`