0.7.1 • Published 6 months ago

@fpjs/overture v0.7.1

Weekly downloads
9
License
MPL-2.0
Repository
gitlab
Last release
6 months ago

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.

Getting Started

The simplest way to explore is by using the repl that comes with @fpjs/overture.

> npx --package='@fpjs/overture' -c repl

This puts you in a repl with all overture modules globally available.

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-2023, 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/.

0.7.1

6 months ago

0.7.0

6 months ago

0.6.1

2 years ago

0.6.0

2 years ago

0.5.0

3 years ago

0.5.2

3 years ago

0.5.1

3 years ago

0.4.1

3 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.2.0

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago