Skip to content

std.syntax.typed_lambda

Intrinsically typed terms of the simply typed lambda calculus. Term(g, t) has type t in context g, and Bound(g, t) selects a binder of type t in that context. Empty is the empty context. Extend(t, g) adds an innermost binder of type t.

The examples on this page run in this module, which opens std.syntax.typed_lambda with the imports and opens the module itself makes:

import std.syntax.typed_lambda
open std.syntax.typed_lambda
import std.syntax.typed_lambda.derive as D
import std.syntax.typed_lambda.named as N

Imports: std.syntax.typed_lambda.derive, std.syntax.typed_lambda.named

Bound (family)

family Bound(g : Ty, t : Ty) : Type

Constructors:

  • Here: constructor Here[c : Ty, a : Ty] : Bound(Extend(a, c), a)
  • There: constructor There[c : Ty, a : Ty, b : Ty] : Bound(c, a) -> Bound(Extend(b, c), a)

A variable with the type of its binder. Each There skips one binder.

Term (family)

family Term(g : Ty, t : Ty) : Type

Constructors:

  • App: constructor App[c : Ty, a : Ty, b : Ty] : Term(c, Arr(a, b)) * Term(c, a) -> Term(c, b)
  • Const: constructor Const[c : Ty, a : Ty] : String -> Term(c, a)
  • Lam: constructor Lam[c : Ty, a : Ty, b : Ty] : Term(Extend(a, c), b) -> Term(c, Arr(a, b))
  • Var: constructor Var[c : Ty, a : Ty] : Bound(c, a) -> Term(c, a)

A checked lambda term. A constant is identified by its label and its declared type. Lam extends the body context and App requires the argument type to match the function's domain.

Ty (index)

index Ty = Base | Next(Ty) | Arr(Ty, Ty) | Empty | Extend(Ty, Ty)

Constructors:

  • Arr
  • Base
  • Empty
  • Extend
  • Next

Function types use Arr. The base type codes Base, Next(Base), and so on can stand for different primitive types in each application.

V0 (pattern)

pattern V0() = Here

The innermost binder, usable in construction and patterns.

V1 (pattern)

pattern V1() = There(Here)

The next binder out.

V2 (pattern)

pattern V2() = There(There(Here))

The third binder out.

declare_terms (computation)

meta define declare_terms(base_types : SynDecl) : Seq[SynDecl] !{refusal}

Declare the typed lambda families and aliases from a local index's primitive types. The splice adds Arr, Empty, and Extend.

define_named (computation)

meta define define_named(declaration : SynDecl) : SynDecl !{refusal}

Splice a local definition written with named lambda binders.