Documentation menu
Language

Builtins

The types, constructors, eliminators and operations that the kernel provides, with the types that the compiler gives them.

Find a section10 sections

The builtins are the names that the kernel knows, and they cannot be defined again. The catalogues below ask the compiler for their types; omegyu type -e 'List/elim' prints the type of one builtin. The worked example evaluates applications instead.

The universe levels of the builtins are implicit arguments, inferred like the others. A level that nothing determines is 0: unit alone is unit @0. In the type of a definition without an annotation, such levels stay free instead (definitions at every level).

Universes and levels

Type, Type l, Kind, which is Type 1, Sort, which is Type 2, and Typeω are the universes. Level, Level/suc, Level/max and Level/imax are the levels (universes), and Reflect describes types (reflection).

Types

Type
{ Bool
, Natural
, Integer
, Double
, Text
, List
, Optional
, Row
, IO
, unit
, Equal
, W
, Word
}
Your result
Complete example · with imports

Type

{ Bool : Type
, Double : Type
, Equal : forall {a : Level} (A : Type a) -> A -> A -> Type a
, IO : forall {a : Level} -> Type a -> Type a
, Integer : Type
, List : forall {a : Level} -> Type a -> Type a
, Natural : Type
, Optional : forall {a : Level} -> Type a -> Type a
, Row : forall {a : Level} -> Type a -> Type a
, Text : Type
, W :
    forall {a b : Level} (A : Type a)
    -> (A -> Type b)
    -> Type (Level/max a b)
, Word : Natural -> Type
, unit : forall {l : Level} -> Type l
}

W A B is the type of the well-founded trees whose nodes are labelled by an A, and whose node labelled x has a child for each B x.

Constructors

Type
{ True, False, Some, None, refl, W/sup }
Your result
Complete example · with imports

Type

{ False : Bool
, None : forall {a : Level} (A : Type a) -> Optional A
, Some : forall {a : Level} {A : Type a} -> A -> Optional A
, True : Bool
, W/sup :
    forall {a b : Level} {A : Type a} {B : A -> Type b} (x : A)
    -> (B x -> W A B)
    -> W A B
, refl : forall {a : Level} {A : Type a} {x : A} -> x === x
}

Eliminators

Type
{ Bool/elim
, Natural/elim
, List/elim
, Optional/elim
, Equal/elim
, W/elim
, Word/elim
, absurd
}
Your result
Complete example · with imports

Type

{ Bool/elim :
    forall {b : Level} (P : Bool -> Type b)
    -> P True
    -> P False
    -> forall (x : Bool)
    -> P x
, Equal/elim :
    forall {a b : Level}
           {A : Type a}
           {x : A}
           (P : forall (y : A) -> x === y -> Type b)
    -> P x refl
    -> forall {y : A} (p : x === y)
    -> P y p
, List/elim :
    forall {a b : Level} {A : Type a} (P : List A -> Type b)
    -> P ([] : List A)
    -> (forall (x : A) (xs : List A) -> P xs -> P ([ x ] # xs))
    -> forall (xs : List A)
    -> P xs
, Natural/elim :
    forall {b : Level} (P : Natural -> Type b)
    -> P 0
    -> (forall (n : Natural) -> P n -> P (n + 1))
    -> forall (n : Natural)
    -> P n
, Optional/elim :
    forall {a b : Level} {A : Type a} (P : Optional A -> Type b)
    -> P (None A)
    -> (forall (x : A) -> P (Some x))
    -> forall (o : Optional A)
    -> P o
, W/elim :
    forall {a b c : Level}
           {A : Type a}
           {B : A -> Type b}
           (P : W A B -> Type c)
    -> (forall (x : A) (f : B x -> W A B)
        -> (forall (y : B x) -> P (f y))
        -> P (W/sup x f))
    -> forall (w : W A B)
    -> P w
, Word/elim :
    forall {l : Level} {bits : Natural} (P : Word bits -> Type l)
    -> (forall (value : Natural) -> P (Word/fromNatural bits value))
    -> forall (w : Word bits)
    -> P w
, absurd :
    forall {a b : Level}
           (P : < ...(||) : Row (Type a) > -> Type b)
           (x : < ...(||) : Row (Type a) >)
    -> P x
}

absurd eliminates the union without alternatives of any universe, which is <> at level 0.

Booleans and naturals

Type
{ Bool/and
, Bool/or
, Bool/equal
, Bool/notEqual
, Natural/plus
, Natural/times
, Natural/subtract
, Natural/div
, Natural/mod
, Natural/isZero
, Natural/show
, Natural/toInteger
, Natural/parse
}
Your result
Complete example · with imports

Type

{ Bool/and : Bool -> Bool -> Bool
, Bool/equal : Bool -> Bool -> Bool
, Bool/notEqual : Bool -> Bool -> Bool
, Bool/or : Bool -> Bool -> Bool
, Natural/div : Natural -> Natural -> Natural
, Natural/isZero : Natural -> Bool
, Natural/mod : Natural -> Natural -> Natural
, Natural/parse : Text -> Optional Natural
, Natural/plus : Natural -> Natural -> Natural
, Natural/show : Natural -> Text
, Natural/subtract : Natural -> Natural -> Natural
, Natural/times : Natural -> Natural -> Natural
, Natural/toInteger : Natural -> Integer
}

Integers and doubles

Type
{ Integer/add
, Integer/multiply
, Integer/negate
, Integer/clamp
, Integer/show
, Integer/toDouble
, Double/add
, Double/subtract
, Double/multiply
, Double/divide
, Double/lessThan
, Double/truncate
, Double/show
}
Your result
Complete example · with imports

Type

{ Double/add : Double -> Double -> Double
, Double/divide : Double -> Double -> Double
, Double/lessThan : Double -> Double -> Bool
, Double/multiply : Double -> Double -> Double
, Double/show : Double -> Text
, Double/subtract : Double -> Double -> Double
, Double/truncate : Double -> Integer
, Integer/add : Integer -> Integer -> Integer
, Integer/clamp : Integer -> Natural
, Integer/multiply : Integer -> Integer -> Integer
, Integer/negate : Integer -> Integer
, Integer/show : Integer -> Text
, Integer/toDouble : Integer -> Double
}

Texts and lists

Type
{ Text/append
, Text/show
, Text/replace
, Text/length
, Text/equal
, Text/chars
, List/length
}
Your result
Complete example · with imports

Type

{ List/length : forall {a : Level} {A : Type a} -> List A -> Natural
, Text/append : Text -> Text -> Text
, Text/chars : Text -> List Text
, Text/equal : Text -> Text -> Bool
, Text/length : Text -> Natural
, Text/replace : Text -> Text -> Text -> Text
, Text/show : Text -> Text
}

Words

Type
{ Word/fromNatural
, Word/fromInteger
, Word/toNatural
, Word/toInteger
, Word/add
, Word/sub
, Word/mul
, Word/div
, Word/sdiv
, Word/mod
, Word/smod
, Word/addmod
, Word/mulmod
, Word/pow
, Word/and
, Word/or
, Word/xor
, Word/not
, Word/shl
, Word/shr
, Word/sar
, Word/clz
, Word/equal
, Word/lt
, Word/slt
, Word/isZero
}
Your result
Complete example · with imports

Type

{ Word/add :
    forall {bits : Natural} -> Word bits -> Word bits -> Word bits
, Word/addmod :
    forall {bits : Natural}
    -> Word bits
    -> Word bits
    -> Word bits
    -> Word bits
, Word/and :
    forall {bits : Natural} -> Word bits -> Word bits -> Word bits
, Word/clz : forall {bits : Natural} -> Word bits -> Natural
, Word/div :
    forall {bits : Natural} -> Word bits -> Word bits -> Word bits
, Word/equal : forall {bits : Natural} -> Word bits -> Word bits -> Bool
, Word/fromInteger : forall (bits : Natural) -> Integer -> Word bits
, Word/fromNatural : forall (bits : Natural) -> Natural -> Word bits
, Word/isZero : forall {bits : Natural} -> Word bits -> Bool
, Word/lt : forall {bits : Natural} -> Word bits -> Word bits -> Bool
, Word/mod :
    forall {bits : Natural} -> Word bits -> Word bits -> Word bits
, Word/mul :
    forall {bits : Natural} -> Word bits -> Word bits -> Word bits
, Word/mulmod :
    forall {bits : Natural}
    -> Word bits
    -> Word bits
    -> Word bits
    -> Word bits
, Word/not : forall {bits : Natural} -> Word bits -> Word bits
, Word/or :
    forall {bits : Natural} -> Word bits -> Word bits -> Word bits
, Word/pow :
    forall {bits : Natural} -> Word bits -> Natural -> Word bits
, Word/sar :
    forall {bits : Natural} -> Natural -> Word bits -> Word bits
, Word/sdiv :
    forall {bits : Natural} -> Word bits -> Word bits -> Word bits
, Word/shl :
    forall {bits : Natural} -> Natural -> Word bits -> Word bits
, Word/shr :
    forall {bits : Natural} -> Natural -> Word bits -> Word bits
, Word/slt : forall {bits : Natural} -> Word bits -> Word bits -> Bool
, Word/smod :
    forall {bits : Natural} -> Word bits -> Word bits -> Word bits
, Word/sub :
    forall {bits : Natural} -> Word bits -> Word bits -> Word bits
, Word/toInteger : forall {bits : Natural} -> Word bits -> Integer
, Word/toNatural : forall {bits : Natural} -> Word bits -> Natural
, Word/xor :
    forall {bits : Natural} -> Word bits -> Word bits -> Word bits
}

Data describes what the operations of words do.

Actions

Type
{ IO/pure
, IO/bind
, IO/putStr
, IO/getLine
, IO/readFile
, IO/writeFile
, IO/args
, IO/getEnv
, IO/exit
, IO/loop
}
Your result
Complete example · with imports

Type

{ IO/args : IO (List Text)
, IO/bind :
    forall {a b : Level} {A : Type a} {B : Type b}
    -> IO A
    -> (A -> IO B)
    -> IO B
, IO/exit : forall {a : Level} {A : Type a} -> Natural -> IO A
, IO/getEnv : Text -> IO (Optional Text)
, IO/getLine : IO (Optional Text)
, IO/loop :
    forall {s : Level} {S : Type s}
    -> S
    -> (S -> IO (Optional S))
    -> IO S
, IO/pure : forall {a : Level} {A : Type a} -> A -> IO A
, IO/putStr : Text -> IO unit
, IO/readFile : Text -> IO Text
, IO/writeFile : Text -> Text -> IO unit
}

What the operations do

Normal form
{ subtract = Natural/subtract 2 10
, divByZero = Natural/div 7 0
, modByZero = Natural/mod 7 0
, clamp = Integer/clamp -3
, shown = Text/show "say \"hi\""
, replaced = Text/replace "a" "o" "banana"
, chars = Text/chars "héllo"
, count = List/length [ 1, 2, 3 ]
, parsed = Natural/parse "12"
, notParsed = Natural/parse "twelve"
, truncated = Double/truncate -2.7
}
Your result
Complete example · with imports

Normal form

{ chars = [ "h", "é", "l", "l", "o" ]
, clamp = 0
, count = 3
, divByZero = 0
, modByZero = 7
, notParsed = None Natural
, parsed = Some 12
, replaced = "bonono"
, shown = "\"say \\\"hi\\\"\""
, subtract = 8
, truncated = -2
}