It is generally known that JavaScript supports a functional style of programming. But because it does not have algebraic data types, the functional programming is usually limited to some simple higher order functions applied to Arrays.

I have often build small libraries that allow working with some aspects of algebraic data types in JavaScript. This time I thought is was cool enough to write a bit about it:

Algebraic Data Types in JavaScript

It includes:

a very small footprint

unfold, map and fold over any adt

merging (read deforestation/fusion) of unfold, map and fold

user defined derived properties (think derived classes Show, Eq...)

I also show how to do the Data Types Ã la carte style of Wouter Swierstra with this library.