Guide
Generic functions
Square-bracket type parameters, inferred at every call — there is exactly one way to call any function.
import lists
fn label[T](x: T, tag: Text) -> Text:
return "{tag}: {x}"
fn main() -> Void:
let names = ["do", "re", "mi"]
print("{lists.index_of(names, "re")}")
print("{lists.reversed(names)}")
print(label(42, "int"))
print(label([1.5], "list"))$ ptc run generics.pt
Recorded output of the real compiler
Since Sprint 32. No turbofish and no call-site type arguments: the declaration rule (every type parameter must appear in a parameter type) makes inference total, and conflicting arguments teach — 'cannot infer index_of: argument 2 is Text, but the arguments so far need Int'. Bodies are checked once with opaque type parameters; monomorphization then generates readable instances like index_of[Int], transitively and across modules. The VM never sees a type parameter.