Skip to content

A minimal functional library for TypeScript featuring monads like Maybe, Either and Result. Built for composability and Rambda compatibility.

License

Notifications You must be signed in to change notification settings

richecr/holo-fn

Repository files navigation

🧠 holo-fn

npm types license tests coverage

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.


✨ Features

  • ✅ Functional types: Maybe, Either, Result
  • ⚙️ Pipe-friendly (Rambda/Ramda compatible)
  • 🔒 Immutable by default
  • 🧪 100% test coverage
  • ⚡️ Zero dependencies
  • 🧠 Full TypeScript inference

🚀 Installation

npm install holo-fn

📦 API Overview

API documentation can be found here

🧠 Examples

Safe object access

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

Optional parsing

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

Changelog

All notable changes to this project will be documented in here.

🤝 Contributing

Please refer to CONTRIBUTING.md for instructions on how to run tests, build the library, and contribute.

📜 License

Here license MIT

About

A minimal functional library for TypeScript featuring monads like Maybe, Either and Result. Built for composability and Rambda compatibility.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published