# Categories as Types

DevFeed: [Categories as Types](<https://devfeed.tech/articles/categories-as-types-40316.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2013/05/04/categories-as-types/>)

Published: 2013-05-04T19:30:35Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [Programming](<https://devfeed.tech/topics/programming.md>), [Standard ML](<https://devfeed.tech/topics/standard-ml.md>), [Programming language](<https://devfeed.tech/topics/programming-language.md>)

Tags: [categories](<https://devfeed.tech/tags/categories.md>), [class](<https://devfeed.tech/tags/class.md>), [exception](<https://devfeed.tech/tags/exception.md>), [functions](<https://devfeed.tech/tags/functions.md>), [functor](<https://devfeed.tech/tags/functor.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [ml](<https://devfeed.tech/tags/ml.md>), [object](<https://devfeed.tech/tags/object.md>), [programming](<https://devfeed.tech/tags/programming.md>), [programming-language](<https://devfeed.tech/tags/programming-language.md>), [type](<https://devfeed.tech/tags/type.md>)

## AI overview

The post explains two ways to represent a category as an ML type: a tuple of functions and an ML functor. It discusses representing objects and morphisms with types, checking composability, and providing identity morphisms while noting which category-theory properties cannot be enforced directly.

## Source excerpt

In this post we'll get a quick look at two ways to define a category as a type in ML. The first way will be completely trivial: we'll just write it as a tuple of functions. The second will involve the terribly-named "functor" expression in ML, which allows one to give a bit more structure on data types. The reader unfamiliar with the ML programming language should consult our earlier primer.