API Reference

Folktale is a suite of libraries for generic functional programming in JavaScript. It allows the construction of elegant, and robust programs, with highly reusable abstractions to keep the code base maintainable.

The library is organised by a variety of modules split into logical categories, with the conventional naming of <Category>.<Module>. This page provides reference documentation for all the modules in the Folktale library, including usage examples and cross-references for helping you find related concepts that might map better to a particular problem.


Provides the most basic and essential building blocks and compositional operations, which are likely to be used by most programs.

  • core.arity
    Restricts the arity of variadic functions.
  • core.check
    Run-time interface checking/contracts for JavaScript values.
  • core.inspect
    Human-readable representations of built-in and custom objects.
  • core.lambda
    Essential functional combinators and higher-order functions derived from λ-Calculus.
  • core.operators
    Curried and first-class versions of JavaScript built-in operators.


Provides operations for control-flow.


Provides functional (persistent and immutable) data structures for representing program data.

  • data.either
    Right-biased disjunctions. Commonly used for modelling computations that may fail with additional information about the failure.
  • data.maybe
    Safe optional values. Commonly used for modelling computations that may fail, or values that might not be available.
  • data.task
    A structure for capturing the effects of time-dependent values (asynchronous computations, latency, etc.) with automatic resource management.
  • data.validation
    A disjunction for validating inputs and aggregating failures. Isomorphic to Data.Either.