Build a custom JavaScript data type that works out of the box with functional libraries like Ramda or Sanctuary without any glue code.
Verify that your library's Functor or Monad implementation follows the correct algebraic laws using the included test suite.
Learn what methods like concat, map, and chain must do so that functional code can compose cleanly across different libraries.
This is a specification document, not installable software, meaningful use requires solid familiarity with functional programming and abstract algebra concepts.
Fantasy Land is not a library you install and run. It is a written specification, a document that defines how certain kinds of data structures in JavaScript should behave so that they can work together without conflicts. Libraries and developers who follow the spec can share code freely because they agree on the rules each structure must follow. The structures defined in the spec come from a branch of mathematics called abstract algebra. Names like Functor, Monad, Applicative, and Semigroup describe patterns for how data can be transformed, combined, or chained. If you have used the array map method in JavaScript, you have used something that fits the Functor pattern. Fantasy Land formalizes those patterns so that any library implementing them correctly can plug into tools built for any other Fantasy Land-compatible library. The specification works by defining what methods an object must have and what rules those methods must obey. For example, a Semigroup must have a concat method, and that method must satisfy the associativity law: combining A with the combination of B and C must give the same result as combining the combination of A and B with C. The document lists these laws precisely for each structure. The practical benefit is that functional programming libraries in JavaScript, such as Ramda, Sanctuary, and others, can interoperate when they follow the spec. If your custom data type implements the right methods correctly, it will work with any tool built around Fantasy Land without any special adapter code. The repository contains the specification text itself and a test suite for verifying compliance. It does not ship runtime code that you call in your application. The full README is longer than what was shown.
← fantasyland on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.