fp-ts

TypeScript 中的函数式编程。「Functional programming in TypeScript」

Github星跟蹤圖

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.

主要指標

概覽
名稱與所有者gcanti/fp-ts
主編程語言TypeScript
編程語言TypeScript (語言數: 2)
平台Linux, Mac, Windows
許可證MIT License
所有者活动
創建於2017-01-25 17:44:09
推送於2025-04-18 09:22:55
最后一次提交2025-04-18 11:22:51
發布數186
最新版本名稱2.16.9 (發布於 )
第一版名稱0.0.1 (發布於 )
用户参与
星數11.2k
關注者數98
派生數512
提交數2.9k
已啟用問題?
問題數819
打開的問題數156
拉請求數867
打開的拉請求數34
關閉的拉請求數121
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?