prelude-js
A modular, tree-shaking friendly implementation of Haskell's Prelude library in modern JavaScript.
import from 'preludejs/Func/compose'
import from 'preludejs/Func/curry'
const = ((: number, : number) => + )
const = (: number) => * 2
// Compose runs right-to-left (double after add(2))
const = (, (2))
const result = (3) // => 10import from 'preludejs/Func/compose'
import from 'preludejs/List/filter'
import from 'preludejs/List/map'
const = (: number) => % 2 === 0
const = (: number) => * 2
// Chain filter then map with right-to-left compose — point-free
const = ((), ())
const result = ([1, 2, 3, 4]) // => [4, 8]import from 'preludejs/Obj/get'
import from 'preludejs/Obj/merge'
const = { : 'ada', : 'admin' }
// get is key-first and curried
const role = ('role', ) // => "admin"
// merge — later sources win
const owner = (, { : 'owner' }) // => { name: "ada", role: "owner" }import from 'preludejs/Str/camelize'
import from 'preludejs/Str/words'
const camel = ('prelude-js-library') // => "preludeJsLibrary"
const list = ('hello functional world') // => ["hello", "functional", "world"]import from 'preludejs/Func/compose'
import from 'preludejs/List/filter'
import from 'preludejs/List/map'
import from 'preludejs/List/sortBy'
import from 'preludejs/Obj/get'
import from 'preludejs/Str/capitalize'
type = { : string; : number }
const : [] = [
{ : 'ada', : 36 },
{ : 'linus', : 12 },
{ : 'grace', : 31 },
]
// adults only, oldest first, names capitalized — composed right-to-left
const = (
((: ) => (('name', ))),
((: ) => -.),
((: ) => . >= 18),
)
const adults = () // => ["Ada", "Grace"]Curried by Default
Multi-argument functions are curried out of the box to make function composition and point-free style effortless.
Fully Typed
Shipped with clean TypeScript (.d.ts) declaration files. Get full type safety and IDE autocomplete in JS/TS.
Functional Composition
Compose operations cleanly with right-to-left compose, Y-combinator fix, memoization, flip, and more.
Tree-Shaking Friendly
Zero external dependencies. Every utility lives in its own file, allowing bundlers to drop unused helpers.