2.0 is out. See what changed

Put what can go wrong in the type.

Option, Either, Try, List and IO for TypeScript. Missing values, errors and effects become types your compiler checks, and so does the agent writing your code.

Read the docs
config.ts
1const port = Option(env.PORT)Option<string>Some("8080")
2 .map(Number)Option<number>Some(8080)
3 .filter((n) => n > 0)Option<number>Some(8080)
4 .getOrElse(() => 3000)number8080
port is a plain number8080PORT="8080" stays a value the whole way down.

Four types for the four ways code goes wrong.

Each has a shape for the value and a shape for what happened instead. You handle the problem once, where it makes sense.

Option<A>

The value may not be there.

Some(a)None
Either<E, A>

It failed, and E says how.

Right(a)Left(e)
Try<A>

The code it ran may throw.

Success(a)Failure(e)
IO<R, E, A>

An effect. It needs services R, can fail with E, and runs only when you run it.

AEDieInterrupted

Building an IO runs nothing.

greet(id) returns a plan. Build it as often as you like and the lookup count stays at zero. It runs when you run it.

0programs built
0lookups run
Nothing built yet.
import { IO, Option, Tag } from "functype"

type User = { readonly id: string; readonly name: string }
class NotFound { readonly _tag = "NotFound" }
const Users = Tag<{
  readonly find: (id: string) => User | undefined
}>("Users")

const greet = (id: string) =>
  IO.service(Users)
    .flatMap((users) =>
      IO.fromOptionOrFail(Option(users.find(id)), () => new NotFound()))
    .map((u) => `Hello, ${u.name}`)
    .catchTag("NotFound", () => IO.succeed("Hello, guest"))

Small and fast, measured.

Against Effect 4.1.5 on Node 24, using the published packages.

Option-only app, gzipped
5.7KB
functype5.7 KB
Effect7.0 KB
App with IO, Either, Option, List
11.5KB
functype11.5 KB
Effect37.3 KB
Build, map and run an effect
32ns
functype32 ns
Effect182 ns

A million chained steps run without a stack overflow, and there are no runtime dependencies.

Your coding agent reads the same docs.

It can search them, check its own code against the compiler and the linter, and load everything as plain text.