Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Category Theory organizes mathematical concepts, and a lot of the concepts there are applicable to Computer Science.

As an example, consider the theory of Containers [0]. A container is an abtract mathematical model of some kind of data structures (such as lists, trees etc.). Like most mathematical structures they form a category. Further more, each container gives rise to a endo-functor Type → Type. In fact they form a full subcategory of such functors.

For instance the list endofunctor L : Type → Type can be seen as a generic data structure which takes a type parameter, A, and gives the type of lists of elements of A, namely L(A). The functor structure is the generic map function which to each f : A → B gives a function map f : L(A) → L(B). These kinds of generic maps are almost always natural transformations, which tells you a lot about their properties. Knowning these things makes it easier to reason about your code.

These are ofcourse very simple examples. For more elaborate applications of containers, see zippers — which involve an adjunction in the form of a differentiation structures. In layman's terms, zippers are datastructures with holes in context.[1]

[0]: http://www.cs.nott.ac.uk/~psztxa/publ/cont-tcs.pdf

[1]: This master thesis has a readable introduction: https://www.duo.uio.no/bitstream/handle/10852/10740/thesisgy...



I really enjoyed learning about the so-called "combinatorial species" [1]. It is another good example of what you are describing. And this idea of differentiation as putting a hole, it just blows my mind every time i think about it.

https://en.wikipedia.org/wiki/Combinatorial_species




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: