Functors & Categories
A functor data type is something you can map over. It’s a container which has a map operation which can be used to apply a function to the values inside it. When you see a functor datatype, you should think “mappable”. In JavaScript, functor types are typically represented as an object with a .map()
method that maps from inputs to outputs, e.g., Array.prototype.map()
. A common analogy is to think of a functor data structure as a box, and map as a way to apply a function to each item contained inside the box, which creates a new box containing the outputs.
In category theory, a functor is a structure preserving map from category ...
Get Composing Software now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.