# Category Theory

## The Voyage

###Objects

- containers/Wrappers for values
- no methods
- not nouns (we won't have
`user`

object or`blog`

object...) - probably won't be making them your own very often

(uses the word functors for them.)

` ````
var _Container = function (val) {
this.val = val
}
```

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

You look at this will immediately know what it does. It's got some properties and grammar

` ````
// associative
add(add(1,2),4) == add(1, add(2,4))
// commulative
add(4,1) == add(1,4)
// identity
add(n, 0) == n
// distributive
multiply(2, add(3,4)) == add(multiply(2,3), multiply(2,4))
```

it's even polymorphic` ````
add('ta', 'cos')
// tacos
add(9.2, 0.5)
// 9.7
add([1,2,3], [4,5,6])
// [1,2,3,4,5,6]
```

we can add anything togetherSo you have

*intuitions*and laws attached.### Category theory

` ````
compose :: (b -> c) -> (a -> b) -> (a -> c)
id :: a -> a
```

It's got laws and properties. It's polymorphic. The above is a

*type signature*. (Haskell type signature)#### The identity function

it returns the same value that was given to it. It's very useful if you want to point free programming.

### Category Laws

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

It doesn't matter how they are grouped. So we can grab out any group of arguments and create subcompositions. This comes from the *associativity*quality.

Doesn't matter how you add three numbers together...