README
Overture
A Javascript library that provides the very basics for functional programming.
Overture aims to be fully compatible with the Fantasy Land Specification, but does not yet implement the complete specification.
Upgrading
A changelog is kept in RELEASES.md
, which lists the major changes.
Usage
Overture provides multiple modules to allow you to import just the ones you
actually use. All imports are relative to the package root @fpjs/overture
.
import {id} from "@fpjs/overture/base";
Algebras
Algebras are implemented in @fpjs/overture/algebras
. Each algebra exports its
related functions, causing some functions being exported by multiple algebras
(e.g. ap
, which is exported by Apply
and Applicative
).
Data structures
Some common data structures such as Identity
and Maybe
are implemented in
@fpjs/overture/data
.
Callback functor
Node.js-style callback functions are notoriously cumbersome to deal with. The
Callback
functor (@fpjs/overture/control/callback
) wraps callback-style
functions and provides Functor
, Applicative
and Monad
instances. This
allows to simply deal with the data in a callback.
Lens
Lenses ease (nested) record attribute access. An implemention is provides in @fpjs/overture/control/lens
.
Built-ins
To use the implementations of various algebras for built-ins (like Array
and
Promise
), the built-in classes can be extended (or: monkey
patched). This is always opt-in; no
modules have side effects just on importing them.
import {patchBuiltins} from "@fpjs/overture/patches";
...
patchBuiltins();
Fantasy Land compatibility
Algebras
- Setoid
- Ord
- Semigroupoid
- Category
- Semigroup
- Monoid
- Group
- Filterable
- Functor
- Contravariant
- Apply
- Applicative
- Alt
- Plus
- Alternative
- Foldable
- Traversable
- Chain
- ChainRec
- Monad
- Extend
- Comonad
- Bifunctor
- Profunctor
Derivations
- derive
fantasy-land/equals
for Ord - derive
fantasy-land/map
for Applicative - derive
fantasy-land/map
for Monad - derive
fantasy-land/map
for Bifunctor - derive
fantasy-land/ap
for Chain
License
Copyright 2019-2020, Bart Bakker.
This software is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.