https://github.com/richecr/holo-fn
A minimal functional library for TypeScript featuring monads like Maybe, Either and Result. Built for composability and Rambda compatibility.
https://github.com/richecr/holo-fn
either-monad functional-programming maybe-monad monads result-pattern typescript
Last synced: about 1 year ago
JSON representation
A minimal functional library for TypeScript featuring monads like Maybe, Either and Result. Built for composability and Rambda compatibility.
- Host: GitHub
- URL: https://github.com/richecr/holo-fn
- Owner: richecr
- License: mit
- Created: 2025-04-16T02:15:50.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-25T23:35:07.000Z (about 1 year ago)
- Last Synced: 2025-05-27T15:11:25.904Z (about 1 year ago)
- Topics: either-monad, functional-programming, maybe-monad, monads, result-pattern, typescript
- Language: TypeScript
- Homepage: https://richecr.github.io/holo-fn/
- Size: 769 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐ง holo-fn





**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
```bash
npm install holo-fn
```
---
## ๐ฆ API Overview
[API documentation can be found here](https://richecr.github.io/holo-fn/)
## ๐ง Examples
### Safe object access
```ts
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
```ts
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](https://richecr.github.io/holo-fn/changelog).
## ๐ค Contributing
Please refer to [CONTRIBUTING.md](https://richecr.github.io/holo-fn/contributing) for instructions on how to run tests, build the library, and contribute.
## ๐ License
[Here license MIT](LICENSE)