Skip to content

Recipes & Patterns

Worked patterns for the situations you’ll actually hit. Each recipe is a small, self-contained example with the code, the lowering, and the design rationale.

Migrating from Python

→ — incremental Python → Typhon, with tyc migrate and manual cleanup.

CLI Application

→ — argparse / click, typed errors, exit codes.

HTTP API with Pydantic

→ — FastAPI + model request/response shapes.

Concurrent Data Fetching

→ — gather: blocks, Result[T, E] propagation, partial-success modes.

Build-Time Env Validation

→ — comptime let + [env] required for fail-fast configuration.

Errors as Values

→ — designing your error types.

State Machines with Sealed Unions

→ — exhaustive transition tables.

Wrapping an Untyped Library

→ — from unsafe: to .dty stub.

Testing Typhon Code

→ — pytest against emitted Python.

CI Integration

→ — tyc check, format-check, stub-drift, type-only second-opinion.