Alpha grammar#
Generated by
debug/docs-set.py. Do not edit by hand: this document is derived from the live compiler, so editing it here would only make it disagree with the language.
Lexical structure#
- an identifier begins with an ASCII letter or
_and continues with letters, digits,_,-,/,.or' - a comment runs from
--to the end of the line - the only delimiters are
(and);:,.and=are their own lexemes - a natural literal is decimal,
0x/0Xhexadecimal or0b/0Bbinary, with_allowed only between digits;-Nis a signed integer literal and1.0e-5a decimal literal (both draft-edition, typed by what they are checked against) "..."is a text literal andb"..."a byte-string literal
Module grammar#
A module is a sequence of line-oriented declarations:
module <qualified-name>
import <qualified-name> -- must name an earlier module
family <Name> : Type <level> -- parameters, indices, constructors, fields, then end-family
def <name> [: <type>] = <term>
Families precede definitions. An import must name a module that appears earlier in the closure, so the module graph is acyclic by construction.
Term forms (92)#
Every form the edition defines, in the syntax the parser accepts:
| form | shape |
|---|---|
app | (app FUNCTION ARGUMENT ...) |
bare-name | X for (family X), C for (constructor F C) |
bind | (bind EFFECTS RESULT COMPUTATION CONTINUATION) |
byte | (byte 0..255) |
byte-and | (byte-and A B) |
byte-equal | (byte-equal A B) |
byte-less-than | (byte-less-than A B) |
byte-or | (byte-or A B) |
byte-shift-left | (byte-shift-left BYTE SHIFT) |
byte-shift-right | (byte-shift-right BYTE SHIFT) |
byte-string-literal | b"BYTES" |
byte-to-nat | (byte-to-nat BYTE) |
byte-xor | (byte-xor A B) |
bytes | (bytes B0 B1 ...) |
bytes-append | (bytes-append A B) |
bytes-builder-append | (bytes-builder-append A B) |
bytes-builder-build | (bytes-builder-build BUILDER) |
bytes-builder-chunk | (bytes-builder-chunk BYTES) |
bytes-builder-empty | (bytes-builder-empty) |
bytes-checksum | (bytes-checksum BYTES) |
bytes-cons | (bytes-cons BYTE BYTES) |
bytes-eliminate | (bytes-eliminate MOTIVE BASE STEP SCRUTINEE) |
bytes-equal | (bytes-equal A B) |
bytes-head | (bytes-head BYTES) |
bytes-index-nonzero | (bytes-index-nonzero BYTES INDEX) |
bytes-length | (bytes-length BYTES) |
bytes-packbits-decode | see docs/language/SPECIFICATION.md |
bytes-set-free-index | (bytes-set-free-index BYTES INDEX DEPTH OFFSET) |
bytes-set-index | (bytes-set-index BYTES INDEX) |
bytes-tail | (bytes-tail BYTES) |
case | (case CONSTRUCTOR BINDER ... . BODY) |
compile-time | (compile-time CLOSED-TERM) |
compiler-native-encode | see docs/language/SPECIFICATION.md |
computation | (computation EFFECTS RESULT) |
constructor | (constructor FAMILY CONSTRUCTOR ARGUMENT ...) |
do | (do EFFECTS RESULT ([QUANTITY] NAME <- COMPUTATION) ... FINAL) |
effect-row | (effect-row) |
effects | (effects E ...) |
eliminate | (eliminate FAMILY MOTIVE SCRUTINEE (branch C BINDER ... . BODY) ...) |
equal | (equal TYPE LEFT RIGHT) |
f32-add | (f32-add A B) |
f32-divide | (f32-divide A B) |
f32-equal | (f32-equal A B) |
f32-less-than | (f32-less-than A B) |
f32-multiply | (f32-multiply A B) |
f32-sqrt | (f32-sqrt A) |
f32-subtract | (f32-subtract A B) |
family | (family NAME ARGUMENT ...) |
first | (first PAIR) |
fsucc | (fsucc BOUND INDEX) |
fzero | (fzero BOUND) |
hole | (hole NAME) |
ih | (ih NAME) |
lambda | (lambda QUANTITY NAME : TYPE . BODY) |
let | (let QUANTITY NAME = VALUE in BODY) |
let* | (let* (QUANTITY NAME [: TYPE] = VALUE) ... in BODY) |
match | (match FAMILY SCRUTINEE (case C BINDER ... . BODY) ...) |
match-with | (match-with FAMILY MOTIVE SCRUTINEE (case C BINDER ... . BODY) ...) |
nat-add | (nat-add A B) |
nat-divide | (nat-divide A B) |
nat-eliminate | (nat-eliminate MOTIVE BASE STEP SCRUTINEE) |
nat-less-than | (nat-less-than A B) |
nat-literal | 0, 1, 2, ... (at Nat, Byte, U16, U32, U64, I8..I64, F32, F64 by expected type) |
nat-modulo | (nat-modulo A B) |
nat-multiply | (nat-multiply A B) |
nat-subtract | (nat-subtract A B) |
nat-to-byte | (nat-to-byte NAT) |
native-physical-image-build | see docs/language/SPECIFICATION.md |
nest | (nest HEAD X1 ... Xn Z) = (HEAD X1 (... (HEAD Xn Z))) |
open-body | (lambda Q X : A . HEAD ARG ...) for (lambda Q X : A . (HEAD ARG ...)) |
pair | (pair SIGMA-TYPE FIRST SECOND) |
partial | (partial COMPUTATION-TYPE) |
pi | (pi QUANTITY NAME : TYPE . RESULT) |
pipe | (pipe X L1 ... Ln) = (Ln ... (L1 X)), X the first operand of each link |
project | (project FAMILY FIELD VALUE) |
prophecy | (prophecy EFFECTS (GHOST : TYPE) (RESOLVED . RESULT) BODY) or (prophecy EFFECTS TYPE RELATION BODY) |
read-file | (read-file PATH) |
record | (record FAMILY (FIELD = VALUE) ...) |
refl | (refl TYPE VALUE) |
resolve | (resolve GHOST VALUE WITNESS) |
return | (return EFFECTS VALUE) |
runtime-image-v4-build | (runtime-image-v4-build BUILDER) |
second | (second PAIR) |
sigma | (sigma QUANTITY NAME : TYPE . RESULT) |
succ | (succ NAT) |
telescope | (lambda Q1 X1 : A1 . Q2 X2 : A2 . BODY), likewise pi and sigma |
text-literal | "TEXT" |
then | (then L1 ... Ln Z) = (L1 (... (Ln Z))) |
transport | (transport MOTIVE PROOF VALUE) |
update | (update FAMILY VALUE (FIELD = VALUE) ...) |
write-file | (write-file PATH CONTENTS) |
zero | zero |
Quantities#
erased, affine, linear, unrestricted. A binder's quantity is part of
its type and is enforced by the kernel: a linear binder used twice is a
ALPHA-QUANTITY-VIOLATION.
The live inventory behind this document (docs/generated/ALPHA-LIVE-FORM-INVENTORY.json, head bb0233466) reconciles 92 surface heads and 80 core constructors with the specification; 0 gap(s).