Skip to main content

Typhon programming language

Project description

Typhon

Typhon is a Python-compatible language with modern syntax: brace-based blocks, static type checking, and expression-oriented features.

Getting Started

Install Typhon via pip:

pip install typhon-language

Run Typhon from the command line:

typhon --help

Create a simple Typhon program in hello.typh:

def main() {
    print("Hello, Typhon!")
}
main()

Run the program:

typhon run hello.typh

Or run directly using uvx:

uvx --from typhon-language typhon run hello.typh

Design Concepts

Typhon is built on three core pillars:

  1. Safety: As expected in modern programming languages, Typhon enforces safety through static typing, lexical scopes, immutable-by-default variables (let), and null safety features (?., ??, ?(), ?[]).
  2. Expressiveness: Expression-oriented design with functional programming features. Control comprehension forms for if, match, try, and so on enable concise, value-returning expressions. Function literals, placeholders and pipe operators facilitate clean and readable code.
  3. Python Interoperability: Typhon compiles directly to Python, allowing you to use the vast ecosystem of Python libraries seamlessly while enjoying a modern syntax.

Sample code

See more examples in Typhon Tests.

Documentation

For a complete guide to the language, please visit the Typhon Reference Manual.

Quick Links

Syntax Changes from Python

Typhon keeps Python semantics where possible, but changes syntax and some safety rules.

Main Changes

  • Brace Scoping: Typhon uses { ... } for blocks instead of indentation. Both ; and line breaks can terminate statements. See Lexical Structure.
  • Static Typing: Type checking is enforced at compile time. Currently powered by basedpyright type checker.
  • Declarations: Variables must be declared with let (immutable) or var (mutable). See Variables.

Syntax Extensions

  • Null Safety: ?., ??, ?(), ?[] operators. See Null Safety.
  • Function literals: Arrow functions such as (x) => { return x + 1 } have the same capability as regular functions. See Function literals.
  • Pipe Operator: x |> f for function chaining. See Pipe Operator.
  • Placeholders: _ for concise anonymous functions (e.g., _ + 1). See Placeholders.
  • Control Comprehensions: Control forms as expressions (for example, (if (c) x else y)). if/while/for/let/try/with/match are supported. See Comprehensions.
  • Pattern Matching: Enhanced match, if-let, and let-else statements. See Control Flow.
  • self Keyword: In non-static methods, self is implicit and explicit self parameters are forbidden (including __init__). See Classes.
  • Data Records: Anonymous immutable records such as {|x = 1|}. See Types.
  • Block Comments: #( ... )# allows nested comments.

Detailed Design Changes

  • Logical Operators: &&, ||, ! replace and, or, not (though Python keywords are still reserved).
  • Operator Notes: ?? is weaker than ||; |>/?|> are weaker than ?? and left-associative; ?-family operators short-circuit.
  • Const Parameters: Function parameters are immutable by default.
  • Header Parentheses Convention: This rule is general: forms that introduce a braced inner scope use parenthesized headers, while forms that declare into the current scope omit them.
  • Assignment Restriction: Reassignment is only to single variable names; pattern reassignment is forbidden.
  • if-let Rule: Single-variable target means None check; non-single target means pattern-success check.
  • Line Breaks: Stricter rules for line continuations. See Lexical Structure.

Syntax Restrictions

Some Python features are removed to enforce safety and clarity. See Removed Features.

  • No del, global, nonlocal.
  • No wildcard imports.
  • No chained assignments (a = b = c).
  • No control statements inside class bodies.

Usage

Typhon can be run directly or translated to Python.

.typh files are Typhon source files. In directory mode, Typhon processes all .typh files.

Typhon uses a .typhon directory under source paths for translated Python and caches. At the same time, .typhon-server is used for language server temporal data.

Run

Run a Typhon source file or directory.

typhon run <source> [args...]

Translate

Translate Typhon code to Python.

typhon translate <source> [-o output_dir]

Type Check

Run type checking on Typhon code.

typhon type_check <source>

Format

Format Typhon source. By default, prints formatted code to stdout. Use -i or --inplace to edit files in place. Abort formatting on syntax error.

typhon format <source> [-i]

Future Plans

See Future Plans for planned features like compile-time controls (static if) and known limitations.

Influenced By

Typhon draws inspiration from several modern programming languages:

  • Python
  • TypeScript
  • Swift
  • Rust
  • Scala
  • F#

Agent Configuration (Copilot / Claude Code)

This repository contains shared agent configuration files:

  • AGENTS.md: repository rules and policies.
  • SKILLS.md: minimal operational workflow and script usage.

Tool-specific entry files refers the shared files:

Repository policy highlights:

  • Use uv run -m ... as the default script execution style.
  • Keep documentation concise, practical, and example-focused rather than long or decorative.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

typhon_language-0.2.0.tar.gz (192.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

typhon_language-0.2.0-py3-none-any.whl (223.7 kB view details)

Uploaded Python 3

File details

Details for the file typhon_language-0.2.0.tar.gz.

File metadata

  • Download URL: typhon_language-0.2.0.tar.gz
  • Upload date:
  • Size: 192.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for typhon_language-0.2.0.tar.gz
Algorithm Hash digest
SHA256 783e48c38a2a5b782f4357fc857702c09638b0f024b5a651ccd8a032bcd64135
MD5 897f00b61359876b74b6575b7bc9a3c3
BLAKE2b-256 e71cf1e72f7392bd455ee15f6ec00ca3e612338bc6ace78bcc6b43f809c33b0d

See more details on using hashes here.

File details

Details for the file typhon_language-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for typhon_language-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76c19c7e80aa01cb3b6cae227d827fc682c7f65c536741ea5f0f25a5a163341a
MD5 e6887df59b379512b5bc2c7fa2c0863a
BLAKE2b-256 9bbd96109d7827a80b2b9cd56f42e9d061cd24256d929586c12e1f17d6baba05

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page