Skip to content

Your first program

A Taipan program is a .tpn file. Its top level runs from top to bottom, as a Python script’s does.

hello.tpn
def greet(name: str) -> str:
return f"Hello, {name}!"
for name in ["Ada", "Grace"]:
print(greet(name))
Hello, Ada!
Hello, Grace!

Run it with taipan run:

Terminal window
taipan run hello.tpn

Before anything runs, the compiler checks the whole program. Function parameters and results are annotated, and everything else is inferred. A mistake is reported with its place and, often, how to fix it, and nothing runs:

hello.tpn
def greet(name: str) -> str:
return f"Hello, {name}!"
let count = 3
print(greet(count))
hello.tpn:5:13: error TP0200: expected str, found int

taipan check checks a program without running it, which is what editors and CI usually want. Each error code has a page under Diagnostics.

taipan build writes a program that runs without the compiler:

Terminal window
taipan build hello.tpn -o out
dotnet out/hello.dll

With --native, it’s a single native executable that doesn’t need .NET installed at all. See Native builds.

Arguments after -- go to the program, as sys.argv:

Terminal window
taipan run copy.tpn -- source.txt target.txt
import sys
if len(sys.argv) < 2:
print("usage: count <word>...")
else:
print(len(sys.argv) - 1, "words")
usage: count <word>...

Set up your editor. If you know Python, read Taipan for Python developers; otherwise, take the Tour of Taipan.