2.0 is out. See what changed

Put what can go wrong in the type. Let your agent check it.

Option, Either, Try, List and IO for TypeScript. Missing values, errors and effects become types the compiler checks. Your coding agent runs the same checks through one MCP call, and every error says what to write instead.

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.

Your agent checks its work before you see it.

One call type-checks and lints the code. Every error names the fix.

The bug compiles. The check doesn't let it through.

users.save returns an Either, so a failed save is a value, not a throw. Drop it and TypeScript says nothing: the user is welcomed whether or not the save worked.

validate_code runs the compiler and functype's lint preset, and the error tells the agent what to write instead.

agent session
  1. You

    Save the new user, then welcome them.

  2. Agent
    7export const register = (user: User): string => {
    8  users.save(user)
    9  return `Welcome, ${user.email}`
    10}
    tsc: 0 errors
  3. validate_code

    ✗ Line 8: This result is dropped, so a failure in it is silently ignored. Check isLeft() / isFailure(), fold it, or return it.functype/no-floating-result

  4. Agent
    -  register = (user: User): string => { …
    +  register = (user: User): Either<SaveError, string> =>
    +    users.save(user).map((saved) => `Welcome, ${saved.email}`)
  5. validate_code

    ✓ PASSED. The code is type-correct and passes the lint preset.

MCP server

validate_code type-checks and lints a snippet before you see it.

npx -y functype-mcp-server

Claude Code plugin

The skills and the MCP server in one install.

/plugin marketplace add jordanburke/functype/plugin install functype

ESLint plugin

One preset where every rule is an error or off, and every message names the fix.

npm i -D eslint-plugin-functype

Docs as text

The whole library in one file, for any model that can fetch a URL.

functype.org/llms-full.txt

How functype works with coding agents

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.

Left(e)Right(a)
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.20.0, with functype built from main.All 10 benchmarks: 8 faster, 1 about the same, 1 slower

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