Package Exports
- fp-ts
- 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/Exception
- fp-ts/lib/Extend
- fp-ts/lib/Field
- fp-ts/lib/Filterable
- fp-ts/lib/Foldable
- fp-ts/lib/Foldable2v
- fp-ts/lib/FoldableWithIndex
- fp-ts/lib/Free
- fp-ts/lib/FreeGroup
- 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/ReaderT
- fp-ts/lib/ReaderTaskEither
- fp-ts/lib/Record
- fp-ts/lib/Semigroup
- fp-ts/lib/Set
- fp-ts/lib/Setoid
- fp-ts/lib/State
- fp-ts/lib/StateT
- fp-ts/lib/StrMap
- 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/Validation
- fp-ts/lib/Writer
- fp-ts/lib/function
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
What is fp-ts?
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 (TypeScript doesn't support HKT natively).
The idea (faking higher kinded types in TypeScript) is based on Lightweight higher-kinded polymorphism
Inspired by
Table of Contents
- Installation and TypeScript compatibility
- Getting started
- Documentation
- Ecosystem
- Type Classes Diagram
- License
Installation and TypeScript compatibility
To install the stable version:
npm install fp-ts
The stable version is tested against TypeScript 3.3.3, but should run with TypeScript 2.8.0+ too
Note. This library is conceived, tested and is supposed to be consumed by TypeScript with the strict
flag turned on.
Note. If you are running < typescript@3.0.1
you have to polyfill the unknown
type. You can use unknown-ts as a polyfill.
Note. 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
).
Getting started
If you are coming from JavaScript:
- read Mostly adequate guide to FP by @DrBoolean
- read this blog series on functional programming in JavaScript by Tom Harding, and then check out the code translated to TypeScript (there's a file for each blog post)
If you are using ramda
If you are coming from TypeScript:
If you are coming from Haskell or Purescript:
Documentation
Blog posts
- Interoperability with non functional code using fp-ts
- Functional design: combinators
- Functional design: how to make the
time
combinator more general - Functional design: tagless final
Tutorials
Beginner
Advanced
- Free monad and
fp-ts
(code) - MTL-style in
fp-ts
(code) - Type safe finite state machines with
IxIO
(code)
Ecosystem
Libraries
- fp-ts-codegen - TypeScript code generation from a haskell-like syntax for ADT
- io-ts - TypeScript compatible runtime type system for IO validation
- monocle-ts - Functional optics: a (partial) porting of scala monocle to TypeScript
- newtype-ts - Implementation of newtypes in TypeScript
- logging-ts - Composable loggers for TypeScript
- fp-ts-routing - A type-safe bidirectional routing library for TypeScript
- parser-ts - String parser combinators for TypeScript
- remote-data-ts - RemoteData type (check this article)
- retry-ts - Retry combinators for monadic actions that may fail
- fp-ts-local-storage - fp-ts bindings for LocalStorage
- circuit-breaker-monad - Circuit Breaker pattern as a monad
Bindings
- fp-ts-rxjs - fp-ts bindings for RxJS
- fp-ts-fluture - fp-ts bindings for Fluture
- fp-ts-most - fp-ts bindings for @most/core
Type Classes Diagram
(click on the diagram to enlarge)
License
The MIT License (MIT)