Skip to content

fp-ts

A TypeScript library bringing common functional programming types like Option and Either.

Stars
11.5k
Forks
506
Licence
MIT
Language
TypeScript
Last update
7 months ago
Type
Library

What it is

fp-ts is a TypeScript library that provides common functional programming building blocks, such as Option, Either, IO, Task, and abstractions like Functor, Applicative, and Monad. It is aimed at developers who want to write code in a functional style with strong type checking. The README notes that it implements Higher Kinded Types, which TypeScript does not support natively. The README also announces that fp-ts is merging into the Effect-TS ecosystem, which it describes as the successor to fp-ts v2.

  • Model optional values with Option instead of null checks
  • Represent success or failure results with Either
  • Compose asynchronous operations using Task
  • Build reusable typed abstractions with Functor, Applicative, and Monad

Great for

  • Developers already familiar with functional programming who want these patterns in TypeScript
  • Teams using TypeScript with strict mode enabled, which the library is designed for
  • Projects that need typed abstractions like Option and Either for error handling
  • Developers maintaining existing codebases that already depend on fp-ts

Not ideal for

  • Beginners learning functional programming, because the docs assume you already know FP concepts
  • New projects that want the newest direction, since the README points users to Effect-TS as the successor to fp-ts v2
  • Projects using TypeScript older than 3.5, since version 2.0.x requires TypeScript 3.5 or newer
Step-by-step guide: how to use fp-tsInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Node.js and npm · TypeScript 3.5 or newer

    Install the stable version

    npm install fp-ts

    Check installed versions

    npm ls fp-ts
  2. 2

    Run it

    • Install the library with npm install fp-ts
    • Enable the strict flag in your TypeScript configuration
    • Import a module such as Option or Either from fp-ts in your code
    • Check the API reference at gcanti.github.io/fp-ts for usage details
  3. 3

    Get the most out of it

    • Read the Learning Resources page linked from the docs to build FP background
    • Check the Ecosystem page for related libraries
    • Keep a single fp-ts version installed to avoid compilation slowdowns
    • Review the Code conventions guide if contributing

Downloads

Strengths

  • Includes widely used types and abstractions modeled on Haskell, PureScript, and Scala
  • Implements Higher Kinded Types, a feature TypeScript lacks natively
  • Documented API reference, learning resources, and an ecosystem page

Trade-offs

  • The README announces a merge into Effect-TS, so the long-term direction of this project is changing
  • Teaching functional programming is out of scope, so beginners will need outside resources
  • Multiple installed versions can cause tsc to hang, so dependency management needs care

How it compares

ProjectStarsTypeLevelUpdatedBest for
fp-ts (this)11.5kLibraryintermediate7 months agoDevelopers already familiar with functional programming who want these patterns in TypeScript
effect17.5kLibraryadvanced4 days agoTeams building large or long-lived TypeScript back-end services
ramda24.1kLibraryintermediate25 days agoJavaScript developers who want to write functional-style data transformations
cyclejs10.2kFrameworkadvanced5 months agoDevelopers who already know reactive streams such as RxJS, xstream, or most.js

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.