lang::construct
lang/src/construct.mo
pub def str (s : String) : TermA string literal.
pub def i64 (n : I64) : TermAn I64 literal, printed with its i64 suffix.
pub def u32 (n : I64) : Termpub def u8 (n : I64) : Termpub def if_ (cond : Term) (then_ : Term) (else_ : Term) : Termif cond then then_ else else_, which is the surface spelling the
printer writes back.
pub def case (ctor : String) (args : List String) (body : Term) : MatchCaseOne positional match arm: ctor args => body.
pub def match_ (scrutinee : Term) (cases : List MatchCase) : Termmatch scrutinee { cases }.
pub def var (idx : I64) (name : String) : TermA bound variable: idx is the de Bruijn index, name only what gets
printed. Use Gen Env (motes/gen) rather than computing an index.
pub def global (name : String) : TermA reference to a top-level name (U32.lt, Option.none): free, hence
the sentinel index, printed exactly as written. A constructor prints
with its type prefix (show_con), so a nullary one reads
Option.none either way.
pub def lam (name : String) (type_ : Term) (body : Term) : Termfn (name : type_) => body.
pub def app (fun : Term) (arg : Term) : Termpub def apps (fun : Term) (args : List Term) : Termpub def con (typ : String) (ctor : String) : TermA nullary constructor: con "Option" "none" prints as Option.none.
pub def con_app (typ : String) (ctor : String) (args : List Term) : TermThe same, applied: con_app "Option" "some" [x].
pub type Vis {
vis_public,
vis_private,
vis_package,
}Declaration visibility. Visibility is package-private, so a
generator names one of these instead.
pub def param (name : String) (type_ : Term) : ParamAn ordinary (name : type) parameter.
pub def attr (name : String) : AttributeAn attribute with no arguments, e.g. attr "partial" for #[partial].
pub def def_text (attrs : List Attribute) (vis : Vis) (name : String)
(params : List Param) (ret : Term) (body : Term) : StringOne declaration in the surface form a human writes:
#[partial]
pub def probe (cp : U32) : Bool :=
if U32.lt cp 10u32 then true else false
params is the parameter list and body the body with those
parameters already peeled, which is Def.params' shape -- not the
Pi/lambda chain Def.typ/Def.term carry. def_of_text renders a
parsed Def this way.
pub def def_of_text (d : Def) : StringThe same, for a Def a parser built: its params, and the result type
and body recovered by peeling the Pi/lambda chain it folded them into.