Skip to content

Types And Inference

Chris Michael edited this page Sep 2, 2026 · 2 revisions

Pudu

Types And Inference

type Box[T] = { value: T }
type MaybePair[A, B] = Pair(A, B) | Missing
type Mapper[A, B] = fn(A) -> B

Status: local inference, annotations, nominal records and sums, generic aliases, tuples, function types, references, traits, and dynamic trait values are checked and interpreted.

Built-in types

Family Types
Signed integers Int8, Int16, Int32, Int64, Int128, Int
Unsigned integers UInt8, UInt16, UInt32, UInt64, UInt128, UInt
Other numbers BigInt, Float32, Float64, Float, Decimal
Scalars Bool, Char, Str, ()
Control Never
Carriers Option[T], Result[T, E], Task[T, E]
Collections Array[T], Map[K, V], Set[T]
References &T, &mut T

Float aliases Float64. Never participates only in unreachable control-flow joins.

Records, sums, and aliases

type Point = { x: Int, y: Int }
type Shape = Circle{ radius: Int } | Rectangle(Int, Int) | Empty
type Predicate[T] = fn(T) -> Bool

Declared records and sums are nominal. Type aliases are transparent. A named variant payload can be positional or record-shaped; the declaration chooses the construction and pattern spelling.

Functions and tuples

fn(Int, Str) -> Bool
async fn(Str) -> Result[Int, Str]
(Int, Str, Bool)

Function types preserve async capability. Calling an async function produces a cold Task whose success and failure channels come from the declared result.

Inference boundary

Literals, local bindings, and private synchronous declarations participate in local inference. Exported and asynchronous signatures require complete annotations. Inference does not choose lossy numeric conversions or invent failure conversions. Trait selection rejects exact normalized duplicate heads; general overlap detection is not implemented.

Unconstrained integer literals default to Int. Context can select another wired-in integer type, and a suffix fixes the width. Public or statement-boundary variables that remain unresolved are diagnostics.

References and ownership status

Borrow and dereference syntax is implemented and explicit: &value, &mut value, and *reference. The compiler checks reference shape, dereference shape, and compiler-controlled Copy eligibility. It does not yet enforce borrow exclusivity, mutable-binding authority for forming &mut, move state, lifetimes, or deterministic destruction. The broader ownership and native-layout model remains a design target, not a completed safety proof.

Related

Clone this wiki locally