Typhon
On this page
The problem
Python’s runtime flexibility is useful, but it also leaves type and control-flow mistakes until execution. I’m exploring how much can be made explicit while keeping readable Python as the output.
What I’m building
Typhon is a statically typed Python dialect. Its Rust toolchain includes the compiler, type checker, language server, formatter and REPL. The compiler emits Python that can be inspected and used with the existing ecosystem.
Design decisions
Result types, nullable values and exhaustive unions make failure and branching explicit. Compiler diagnostics and editor feedback are part of the language, rather than additions after syntax design.
A small source example illustrates the intent:
def double(value: int) -> int:
return value * 2
The important boundary is between checked source and ordinary Python output. The repository documents the supported syntax and the compiler’s current behaviour.
Evidence and status
The public repository includes the Rust compiler, examples, tests and documentation site. This is an evolving language project; syntax and supported features should be checked against that version’s documentation.
A complete toolchain
The tyc executable brings the compiler and daily development commands together. check parses and type-checks without emitting files, build writes Python and source maps, fmt formats source, and lsp supplies diagnostics, hover information, navigation and completion to an editor. run can use the in-process interpreter; building and running the emitted Python is a separate path.
tyc init myapp
cd myapp
tyc check src/
tyc build
python build/main.py
The emitted code targets CPython 3.13 or newer. The generated application can run without installing the Typhon toolchain, which makes inspecting the compiler’s output and using ordinary Python deployment workflows practical.
What the type system makes explicit
Parameters and return values are annotated. Local bindings distinguish let from mut; a nullable type is written as T?. Structural interfaces describe capabilities, and sealed unions describe a closed set of alternatives. Result[T, E] makes a function’s error cases visible in its signature.
Those rules connect language design to everyday maintenance. Changing a union can reveal callers that need a new branch. Making a value nullable tells the caller where an absence must be handled. Diagnostics need to identify that boundary clearly enough to fix it.
Read the behaviour, then the plan
The project is evolving. One documented gap is checking variants nested inside the Ok or Err arms of a match on an enclosing Result. That distinction matters when reading an example or deciding which guarantees a particular version provides.
Start with the language reference, then compare the supported syntax with the emitted Python in the programming guides. The CLI guide covers the compiler and developer commands. The roadmap records work still to come.