a lightweight algebraic structure library
Find a file
2025-03-31 05:27:48 -05:00
src doc cleanup; export curry 2025-03-31 05:22:59 -05:00
tests overhaul monad impls 2025-03-29 06:09:49 -05:00
.gitignore initial commit 2025-03-26 21:28:33 -05:00
jsconfig.json refactor 2025-03-31 05:10:46 -05:00
package-lock.json overhaul monad impls 2025-03-29 06:09:49 -05:00
package.json initial commit 2025-03-26 21:28:33 -05:00
README.md fix type in readme: bind -> chain 2025-03-31 05:27:48 -05:00

kojima

a small functional/monad library

Usage

Example

import { Option, Some, None, Result, Ok, Err } from 'kojima'

const maybe = Option.of('thing')
maybe.isSome() // true
const isnt = maybe.chain(None).map(_x => 'other') // None
isnt.isSome() // false

const result = Result.of('3:41am')
result.isOk() // true

result.chain(() => Err(new Error(-Infinity)))
    .map(_x => '4:10am')
    .chain(Ok)

result.isErr() // true

// crimes!
None == None() // true