FP
UTILS
fp is a lightweight TypeScript library designed to simplify functional programming by providing essential types like Option and Result. It helps developers handle errors, manage optional values, and write expressive, composable code.
But Why FP?
In TypeScript, the “happy path” is easy — it’s the nulls, undefineds, and errors that quietly add boilerplate. @carbonteq/fp gives you small, focused primitives (like Option and Result) so you can model uncertainty and failure explicitly without rewriting everything around a new runtime.
If you’re already using Effect, fp is the “grab-bag” tier: similar ergonomics for everyday data-flow, but with less setup when all you want is typed composition around values.
import { } from "@carbonteq/fp";
type = { : string; : boolean };
declare const : | null;
const = .()
.(() => .)
.(() => .)
.("unverified@example.com");
.(email);import { } from "effect/Function";
import * as from "effect/Option";
import * as from "effect/Effect";
type = { : string; : boolean };
declare const : | null;
const = .(() =>
(
.(),
.(() => .),
.(() => .),
.(() => "unverified@example.com"),
),
);
const = .();
.(email);What you get
Sync + async, one flow
Write the same pipeline whether steps are synchronous or asynchronous. Compose transformations, validations, and fallbacks without splitting your codebase into “sync” and “async” versions.
- Chain sync + async steps
- Keep types consistent end-to-end
- Stay readable as complexity grows
Tiny footprint
Get the ergonomics you need without pulling in a whole ecosystem. fp is intentionally small so you can adopt it incrementally — per function, per module, per service.
- Minimal API surface
- Small bundle size
- Easy incremental adoption
Never try & catch again
Model failure explicitly with Result and keep the happy path clean. Handle errors where they matter, with types guiding what you’ve covered (and what you haven’t).
- Type-safe errors & values
- Combinators for recovery
- No hidden thrown exceptions
Safer code, simpler flow
Doing the right thing in TypeScript is hard. fp makes it easier by giving you small, predictable primitives.
- Handle errors, async code, concurrency and streams with composable primitives.
- Reduce one-off dependencies by leaning on a coherent core.
- Integrates cleanly with your existing stack.
import { } from "@carbonteq/fp";
type = { : string };
type = "NotFound" | "DbDown";
declare function (: string): <, >;
declare const : string;
const user = ();type = { : string };
declare function (: string): ;
declare const : string;
// what can this throw? you have to read the code
const user = ();