A minimal functional library for TypeScript featuring monads like Maybe
, Either
and Result
. Built for composability and Rambda compatibility.
💡 Designed to work seamlessly with
pipe
from Rambda. Fully typed, immutable, and safe by default.
- ✅ Functional types:
Maybe
,Either
,Result
- ⚙️ Pipe-friendly (Rambda/Ramda compatible)
- 🔒 Immutable by default
- 🧪 100% test coverage
- ⚡️ Zero dependencies
- 🧠 Full TypeScript inference
npm install holo-fn
API documentation can be found here
import { fromNullable, match } from 'holo-fn/maybe';
const double = (n: number) => n * 2;
const result = pipe(
[5, 5, 6],
(ns) => fromNullable(head(ns)),
(x) => x.map(double),
match({
just: (n) => n,
nothing: () => -1
})
);
console.log(result); // 10
import { fromNullable } from 'holo-fn/maybe';
const parsePrice = (input: string) =>
fromNullable(parseFloat(input))
.map(n => (n > 0 ? n : null))
.chain(fromNullable)
.unwrapOr(0)
console.log(parsePrice('123.45')) // 123.45
console.log(parsePrice('0')) // 0
console.log(parsePrice('-123.45')) // 0
console.log(parsePrice('abc')) // 0
All notable changes to this project will be documented in here.
Please refer to CONTRIBUTING.md for instructions on how to run tests, build the library, and contribute.