Category Theory in Computing Languages

​Is there any connection between category theory and the way computer languages work? by Thorsten Altenkirch 

Yes, lots.

Just one example: a function with 2 inputs from A and B and results from C would have the type A x B -> C but in functional languages like Haskell we are using A -> (B -> C), i.e. a function that returns a function. This “currying” is exactly a the categorical definition of a cartesian closed category as one where Hom(AxB,C) is isomorphic to Hom(A,B -> C) and in this false you can replace Hom(X,Y) with X -> Y.

It is well known that effects in functional programming can be modelled by monads which is a concept from category theory. Nowadays a weaker structure called applicative functors has become very popular – needless to say also a concept from Category Theory.

Not all languages are functional (yet) but even non-functional languages can be understood using concepts from category theory.

See also: 

Free Categories, Free MonoIds, Monads = MonoId+Endofunctor

Monad Diagram


2 thoughts on “Category Theory in Computing Languages

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s