No matching definitions.

tur/nat

stdlib/nat.tur

type-level natural numbers via GADT for phantom length annotations.

Since: Phase G4

defn

nat-zero

(nat-zero :Nat)

construct the Zero natural number.

A (Nat) value representing zero.

(nat-zero)  ; => Zero

Since: Phase G4

defn

nat-succ

(nat-succ [n :Nat] :Nat)

construct the successor of a natural number.

nthe predecessor (Nat) value

A (Nat) value representing n+1.

(nat-succ (nat-zero))  ; => Succ(Zero)

Since: Phase G4

defn

nat-to-int

(nat-to-int [n :Nat] :int)

convert a type-level Nat to a runtime integer.

nthe (Nat) value to convert

The integer representation of n.

(nat-to-int (Succ (Succ (Zero))))  ; => 2

Since: Phase G4

defn

nat-add

(nat-add [a :Nat b :Nat] :Nat)

add two type-level Nat values.

afirst (Nat) value
bsecond (Nat) value

A (Nat) representing a + b.

(nat-to-int (nat-add (Succ (Zero)) (Succ (Succ (Zero)))))  ; => 3

Since: Phase G4