Modules
A program is a main file and the modules it imports. A module is a .tpn file beside the main file, and holds declarations only: functions, classes, enums, constants, protocols and type aliases. Only the main file has a top level that runs.
const UNIT = "cm"
enum Shape: Circle(radius: float) Square(side: float)
def area(s: Shape) -> float: match s: Circle(r): return 3.14159 * r * r Square(side): return side * sideimport shapesfrom shapes import Circle, Square, area as area_of
let items = [Circle(1), Square(2), shapes.Shape.Square(3)]for item in items: print(item, f"{area_of(item):.2f} {shapes.UNIT}²")Circle(radius=1.0) 3.14 cm²Square(side=2.0) 4.00 cm²Square(side=3.0) 9.00 cm²import shapesbinds the module; its names are thenshapes.area,shapes.Shape,shapes.UNIT.from shapes import area, Shapebinds names directly, and importing an enum binds its variants too.asrenames:import shapes as s,from shapes import area as area_of.- A module exports every name it defines. Imports can be cyclic, since definitions are hoisted.
Each module is checked on its own terms, and an error names the file it’s in.
Built-in modules
Section titled “Built-in modules”sys, os, types and asyncio are part of Taipan:
import sysfrom os import environ, getenv
print(len(sys.argv) >= 1, getenv("TAIPAN_DOCS_UNSET") ?? "unset", "PATH" in environ)True unset Truesys:argv,exit,stdin,stdoutandstderr.os:environandgetenv.types:TracebackType, for__exit__.asyncio:run,gather,sleep,wait_forandtimeout. See Async.
Two more roots are reserved: from python import json imports a Python module (Calling Python), and from dotnet.System.IO import File imports .NET types (Using .NET).
Next: Iterators and generators.
© 2026 Discover Edge, LLC · Taipan is released under the MIT License.