fp-ts

Typed functional programming patterns and data types for TypeScript

Library
npm
v2.16.11
11,538stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
55/100Fair
Development Activity12
Maintenance44
Community64
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
74/100Good
Architecture80
Code Quality82
Innovation78
Learning Curve55

fp-ts brings the core abstractions of typed functional programming to TypeScript, providing data types like Option, Either, Task, and TaskEither alongside the type classes (Functor, Monad, Applicative) and combinators needed to compose them. Rather than a single opinionated framework, it’s a toolbox of small, composable modules that let developers model absence, errors, and asynchronous effects explicitly in the type system instead of relying on exceptions or null.

The library popularized pipe-based, point-free composition in the TypeScript ecosystem and has been a foundational dependency for many typed-FP libraries built on top of it. Its author has since joined the Effect-TS organization, with Effect positioned as fp-ts’s spiritual successor, but fp-ts itself remains a separately maintained, widely depended-upon package.

What You Get

  • Core algebraic data types: Option, Either, Task, TaskEither, IO, IOEither, and more
  • Type class abstractions (Functor, Applicative, Monad, Foldable) implemented consistently across data types
  • pipe and flow utilities for point-free, left-to-right function composition
  • A large, tree-shakeable module set so consumers only bundle the pieces they import
  • Extensive dtslint-verified type-level tests ensuring inference behaves correctly across TypeScript versions

Common Use Cases

  • Replacing null/undefined checks with Option to make absence explicit and type-checked
  • Modeling fallible operations with Either/TaskEither instead of throwing and catching exceptions
  • Composing asynchronous, potentially-failing workflows (TaskEither) in a railway-oriented style
  • Building typed functional libraries (parsers, validators, state machines) on top of fp-ts’s type classes

Under The Hood

Architecture - fp-ts is organized as roughly 123 independent modules under src/, one per data type or type class (Option.ts, Either.ts, TaskEither.ts, Functor.ts, etc.), each exporting pure functions and standalone type class instances rather than classes with methods, so the library composes entirely through pipe/flow rather than object-oriented chaining. Tech Stack - written in TypeScript with dual CommonJS (lib/) and ES6 (es6/) build outputs, docs-ts for auto-generated API documentation from JSDoc, and dtslint for type-level regression testing alongside vitest for runtime tests. Code Quality - the test/ directory holds 81 test files against 123 source modules, combined with dtslint’s type-level assertions, ESLint, and Prettier enforced via the test npm script, giving fp-ts unusually strong guarantees for both runtime behavior and type inference correctness. API Design - the library favors small, single-purpose exports and consistent naming conventions across data types (map, chain, of, fold) so patterns learned on one type (e.g. Option) transfer directly to others (Either, TaskEither), though the functional/point-free style itself has a real learning curve for developers unfamiliar with FP idioms.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search