0.10.0 • Published 2 years ago
@neotype/prelude v0.10.0
neotype_prelude
Functional programming essentials for TypeScript
Quick links
Features
- Tools for comparing values: use the contracts provided by the
EqandOrdinterfaces to implement equivalence relations and total orders. - Tools for combining values: use the contract provided by the
Semigroupinterface to implement semigroups. - Algebraic data types:
- Model optional values with
Maybe. - Handle failures with
Either. - Validate forms and user input with
Validation. - Get creative with more types like
IorandPair.
- Model optional values with
- Generator comprehensions: chain computations together by writing imperative style code blocks using a coroutine syntax.
- Async generator comprehensions: work with
Promisevalues inside of generator comprehensions usingasync/awaitsyntax.
Install
neotype_prelude is available on NPM.
npm install @neotype/preludeWorking with modules
This library provides a suite of ES6 modules. A .js suffix is required in
all import statements. All modules provide named exports.
import { cmb, Semigroup } from "@neotype/prelude/cmb.js";
import { cmp, eq, Eq, Ord } from "@neotype/prelude/cmp.js";
import { Either } from "@neotype/prelude/either.js";
import { Maybe } from "@neotype/prelude/maybe.js";
// etc.See each module's documentation for recommended import practices and available exports.
Inspiration
This library takes inspiration from many existing functional programming languages and libraries, including: