Tagged Maybe for expected absence — cache miss, optional field, not-ready-yet. Not for failures (use @onrails/result).
bun add @onrails/maybe
import { compactMap, fromNullable, isSome, match, some } from "@onrails/maybe";
const row = fromNullable(db.get(id));
const name = match(
row,
(r) => r.name,
() => "guest",
);
import { toResult } from "@onrails/maybe/interop";
const user = toResult(fromNullable(row), () => ({ kind: "not_found" as const }));
| Path | Contents |
|---|---|
@onrails/maybe |
Core |
@onrails/maybe/fluent |
fluent(maybe) chains |
@onrails/maybe/interop |
toResult, fromResult, NoneError |
See DESIGN.md.