A functional programming library for JavaScript and TypeScript
This is not ready yet (both conceptually and in terms of implementation) I recommend using the following if anything here sounds interesting:
Alternatively, wait ~3 years for the ECMAScript pipe and pattern matching proposals to reach stage 3, and wait for TypeScript or flow to implement these features, as that would make this library redundant.
To create a "standard library" of objects and functions which box native JavaScript data and provide a method-chaining interface to act on said data.
Ultimately, this should allow method chaining in complete lieu of pipes, and avoid the need for a lot of code branching.
- To have fun
- To learn about Fantasy Land and Static Land
- To learn about what lies beyond those specifications
- To make JavaScript more Scala-y but without me having to learn how SBT works
- To provide a proof of concept for this kind of programming in general
- To sketch out some ideas that someone hopefully more capable can use
const nine =
Num.from(9) // alternatively Num.of(9) but... (1)
.add(10) // Semiring `+`
.times(2) // Semiring `*`
.minus(3) // shorter than `subtract`? (2)
(1) I don't want to give the impression that Num is necessarily a Applicative (2) I'm not sure if there's some rules about etymological consistency I'm breaking here. All of these terms have a lot of synonyms in colloquial mathematics, I'm just going for the shorter ones.