JSPM

fp-ts

2.7.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2884166
  • Score
    100M100P100Q195378F
  • License MIT

Functional programming in TypeScript

Package Exports

  • fp-ts
  • fp-ts/es6/Apply
  • fp-ts/es6/Array
  • fp-ts/es6/Const
  • fp-ts/es6/Date
  • fp-ts/es6/Either
  • fp-ts/es6/EitherT
  • fp-ts/es6/Eq
  • fp-ts/es6/Filterable
  • fp-ts/es6/Foldable
  • fp-ts/es6/IO
  • fp-ts/es6/IOEither
  • fp-ts/es6/IORef
  • fp-ts/es6/Identity
  • fp-ts/es6/Monoid
  • fp-ts/es6/NonEmptyArray
  • fp-ts/es6/Option
  • fp-ts/es6/OptionT
  • fp-ts/es6/Ord
  • fp-ts/es6/Reader
  • fp-ts/es6/ReaderEither
  • fp-ts/es6/ReaderT
  • fp-ts/es6/ReadonlyArray
  • fp-ts/es6/ReadonlyRecord
  • fp-ts/es6/Record
  • fp-ts/es6/Semigroup
  • fp-ts/es6/Set
  • fp-ts/es6/Show
  • fp-ts/es6/StateT
  • fp-ts/es6/Task
  • fp-ts/es6/TaskEither
  • fp-ts/es6/These
  • fp-ts/es6/Tree
  • fp-ts/es6/boolean
  • fp-ts/es6/function
  • fp-ts/es6/pipeable
  • fp-ts/lib/Applicative
  • fp-ts/lib/Apply
  • fp-ts/lib/Array
  • fp-ts/lib/Array.js
  • fp-ts/lib/BooleanAlgebra
  • fp-ts/lib/Bounded
  • fp-ts/lib/BoundedDistributiveLattice
  • fp-ts/lib/Chain
  • fp-ts/lib/ChainRec
  • fp-ts/lib/Choice
  • fp-ts/lib/Compactable
  • fp-ts/lib/Console
  • fp-ts/lib/Const
  • fp-ts/lib/Contravariant
  • fp-ts/lib/Date
  • fp-ts/lib/DistributiveLattice
  • fp-ts/lib/Either
  • fp-ts/lib/Either.js
  • fp-ts/lib/EitherT
  • fp-ts/lib/Eq
  • fp-ts/lib/Extend
  • fp-ts/lib/Field
  • fp-ts/lib/Filterable
  • fp-ts/lib/Foldable
  • fp-ts/lib/FoldableWithIndex
  • fp-ts/lib/Functor
  • fp-ts/lib/FunctorWithIndex
  • fp-ts/lib/IO
  • fp-ts/lib/IOEither
  • fp-ts/lib/IOEither.js
  • fp-ts/lib/IORef
  • fp-ts/lib/Identity
  • fp-ts/lib/Map
  • fp-ts/lib/Monoid
  • fp-ts/lib/NonEmptyArray
  • fp-ts/lib/Option
  • fp-ts/lib/Option.js
  • fp-ts/lib/OptionT
  • fp-ts/lib/Ord
  • fp-ts/lib/Ordering
  • fp-ts/lib/Random
  • fp-ts/lib/Reader
  • fp-ts/lib/ReaderEither
  • fp-ts/lib/ReaderT
  • fp-ts/lib/ReaderTask
  • fp-ts/lib/ReaderTaskEither
  • fp-ts/lib/ReadonlyArray
  • fp-ts/lib/ReadonlyNonEmptyArray
  • fp-ts/lib/ReadonlyRecord
  • fp-ts/lib/Record
  • fp-ts/lib/Semigroup
  • fp-ts/lib/Set
  • fp-ts/lib/Show
  • fp-ts/lib/State
  • fp-ts/lib/StateT
  • fp-ts/lib/Task
  • fp-ts/lib/TaskEither
  • fp-ts/lib/These
  • fp-ts/lib/Traversable
  • fp-ts/lib/Tree
  • fp-ts/lib/Tree.js
  • fp-ts/lib/Tuple
  • fp-ts/lib/Writer
  • fp-ts/lib/boolean
  • fp-ts/lib/function
  • fp-ts/lib/pipeable

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fp-ts) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Functional programming in TypeScript

build status dependency status npm downloads

Typed functional programming in TypeScript

fp-ts is a library for typed functional programming in TypeScript.

fp-ts aims to allow developers to use popular patterns and abstractions that are available in most functional languages. For this, it includes the most popular data types, type classes and abstractions such as Option, Either, IO, Task, Functor, Applicative, Monad to empower users to write pure FP apps and libraries built atop higher order abstractions.

A distinctive feature of fp-ts with respect to other functional libraries is its implementation of Higher Kinded Types, which TypeScript doesn't support natively.

Inspired by

Table of contents

Installation

To install the stable version:

npm install fp-ts

Make sure to always have a single version of fp-ts installed in your project. Multiple versions are known to cause tsc to hang during compilation. You can check the versions currently installed using npm ls fp-ts (make sure there's a single version and all the others are marked as deduped).

Consuming fp-ts

Most examples will use the following import syntax:

import { Option, some, none } from 'fp-ts/lib/Option'

This will give you the widest support across tools, as you will be importing CommonJS modules.

If you use a bundler such as webpack or Rollup that supports tree-shaking, you can take advantage of this by opting to import ECMAScript modules instead:

import { Option, some, none } from 'fp-ts/es6/Option'

Note that there are caveats such as some tools (e.g. Jest) not supporting ES6 module syntax natively yet.

TypeScript compatibility

Strictness – This library is conceived, tested and is supposed to be consumed by TypeScript with the strict flag turned on.

fp-ts version required typescript version
2.0.x+ 3.5+
1.15.x+ 3.1+
<= 1.14.4 2.8+ (*)

(*) If you are running < typescript@3.0.1 you have to polyfill the unknown type. You can use unknown-ts as a polyfill.

Documentation

Disclaimer. Teaching functional programming is out of scope of this project, so the documentation assumes you already know what FP is.

Development

License

The MIT License (MIT)