fp-ts
Typed functional programming patterns and data types for TypeScript
Repository Health
Technical Analysis
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
pipeandflowutilities 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/undefinedchecks withOptionto make absence explicit and type-checked - Modeling fallible operations with
Either/TaskEitherinstead 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.
Used by 3 apps in this directory
Bigcapital
Invoicing Finance
Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.
Hoppscotch
Developer Tools
A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.
Kibana
Analytics · Monitoring
Your open source window into the Elastic Stack — query, visualize, and act on data stored in Elasticsearch with real-time dashboards, AI-assisted search, and automated alerting.