Skip to content

Latest commit

 

History

History
84 lines (54 loc) · 3.46 KB

README.md

File metadata and controls

84 lines (54 loc) · 3.46 KB

functional-libs-in-typescript

Survey of functional programming libs usable in Typescript

Because of their generic nature, using Javascript utility libraries with Typescript has often been tedious. Libraries need to be designed to support type interencing of parameters and return values.

This is a cursory survey of FP libraries that claim Typescript support. Many are Typescript-centric. I have not tried these; this is just an aid to help narrow down the set of libraries to evaluate.

Some libraries were not studied because they didn't meet these support criteria:

  • has well-supported types (even if only in DefinitelyTyped)
  • doesn't demonstrate indifference toward typescript support
  • has commits in the last year
  • has documentation
  • has been published to npm, with at least one additional release
  • more than just one function
  • general-purpose

Criteria reviewed

  • number of contributors
  • is written in typescript
  • number of outstanding typing-related issues
  • supports iterator chaining if relevant
  • supports left-to-right function chaining (pipe vs. compose) if relevant

Areas supported

  • Collections
  • Either
  • Option / Maybe
  • Try
  • Immutables
  • Pipe
  • Async

Candidates

  • collectable - high-performance, persistent, immutable, functional data structures, a la Scala
  • fp-ts - a coherent collection of abstract datatypes and type classes, grounded in category theory, a la Scala.
  • funfix - complete implementations of Option, Either, and Try, a la Scala. 
  • immer - typically used for React state management; supports semi-immutable objects that are only mutable within a well-defined scope
  • iter-tools - a rich toolset for working with iterables, both sync and async
  • monet - Scala-derived Either, Maybe, immutable List, and a few more.
  • pratica - Maybe, Result.
  • prelude.ts
  • purify
  • ramda
  • remeda
  • sanctuary
  • tifi

The inclusion of ramda is questionable, done largely because it's the dominant JS FP utility lib. Typescript friendliness was never a consideration in its API design. There are two type libraries for it: one in DefinitelyTyped, with many authors and recent PR's and a second, referenced in the Ramda documentation, in github.com/types/npm-ramda, which has not been updated in over a year.

Not studied