Skip to content

tyc init

tyc init [NAME] [--dir DIR]

Creates a new Typhon project with a fully-commented typhon.toml, a src/main.ty that demonstrates every core feature (frozen dataclass, impl block, mut binding, Result[T, E] with ? propagation, match), and an empty tests/ directory.

Examples

Terminal window
tyc init hello # creates ./hello/
tyc init hello --dir /tmp # creates /tmp/hello/
tyc init # initialises the current directory (project name = directory name)

What gets generated

hello/
├── typhon.toml # Commented config — the commonly-tuned [strictness]/[emit] keys
├── src/
│ └── main.ty # Worked example: frozen class + impl + mut + Result/?/match
├── tests/ # Empty; pytest works out of the box
└── .gitignore # Excludes build/ and target/

The scaffolded src/main.ty is intentionally rich. It compiles, runs cleanly under tyc run, and exercises the constructs you’ll use every day:

let greeting: str = "Hello from Typhon!"
# A `frozen` dataclass: immutable, hashable, slotted at runtime. The
# `frozen` modifier follows the class name.
class Greeting frozen:
name: str
# Methods live in `impl Greeting:` blocks, not in the class body (Rule 4).
impl Greeting:
def greet(self) -> str:
return f"Hello, {self.name}, from Typhon!"
# `Result[T, E]` + `?` for railway-style error propagation.
def parse_count(s: str) -> Result[int, str]:
try:
return Ok(int(s))
except ValueError:
return Err(f"not an int: {s}")
def doubled_count(s: str) -> Result[int, str]:
let n: int = parse_count(s)?
return Ok(n * 2)
def main() -> None:
print(greeting)
let hello: Greeting = Greeting(name="hello")
print(hello.greet())
# Local `mut` binding: rebindable, but only to new values of the
# declared type. `let` would forbid the increment below.
mut count: int = 0
count = count + 1
print(f"count is now {count}")
match doubled_count("21"):
case Ok(value):
print(f"doubled: {value}")
case Err(reason):
print(f"failed: {reason}")
if __name__ == "__main__":
main()

You’ll edit this as the project grows. See typhon.toml Overview for every key.

The generated typhon.toml leaves the optimiser knobs (auto-memoise, auto-gather, auto-parallel, pgo-memoise) unset, so they follow [optimise] level: off by default, on with level = 1 or under tyc build -O. Writing one of them into [strictness] overrides both.

Flags

FlagDefaultEffect
--dir DIR (-d).Parent directory for the new project. When NAME is also given, the scaffold lands in <dir>/<NAME>/. When NAME is omitted, the directory’s own name is used as the project name.

What tyc init doesn’t do

  • It does not run git init. Run that yourself if you want a repository.
  • It does not install dependencies. Use tyc add for that, or run tyc build and let the bundled uv sync step handle it.
  • It does not create a virtualenv. The first tyc build materialises .venv via uv sync automatically.
  • It does not overwrite anything. An existing typhon.toml or src/main.ty — or a symlink at either path — stops it before it writes a single file.

Where next