Skip to content

11. Appendix

11.1. Grammar reference

The authoritative grammar is D7 §7. This appendix summarises the surface forms covered in this guide and notes the post-D7 additions (sized bounded binders from Phase 11h, institution-capability syntax from Phase 11e.1).

11.1.1. Top-level

File ::= NamespaceDecl* Declaration*
NamespaceDecl::= 'namespace' Identifier '=' StringLit ';'
Declaration ::= ClassDecl | PropertyDecl | ResourceDecl
| DataDecl | CodataDecl | ProgramDecl

11.1.2. Class, property, resource

ClassDecl ::= 'class' QualifiedName (':' QualifiedName)? '{' ClassItem* '}'
ClassItem ::= 'description' '=' StringLit ';'
| 'requires' QualifiedName (',' QualifiedName)* ';'
| 'recommends' QualifiedName (',' QualifiedName)* ';'
PropertyDecl ::= 'property' QualifiedName ':' QualifiedName '{' PropertyItem* '}'
PropertyItem ::= 'description' '=' StringLit ';'
| 'min_value' '=' Number ';'
| 'max_value' '=' Number ';'
| 'min_length' '=' Integer ';'
| 'max_length' '=' Integer ';'
| 'pattern' '=' StringLit ';'
| 'format' '=' QualifiedName ';'
| 'allows_only' '=' Value (',' Value)* ';'
| 'domain' '=' QualifiedName (',' QualifiedName)* ';'
| 'class_types' '=' QualifiedName (',' QualifiedName)* ';'
| 'element_type' '=' QualifiedName ';'
ResourceDecl ::= 'resource' QualifiedName ':' QualifiedName '{' ResourceField* '}'
ResourceField ::= QualifiedName '=' Value ';'
Value ::= StringLit | Integer | Float | Boolean
| QualifiedName (* IRI ref *)
| '[' Value (',' Value)* ']' (* array *)
| '{' ResourceField* '}' (* embedded resource *)

11.1.3. Data and codata

DataDecl ::= 'data' QualifiedName ParamList? '{' Ctor (',' Ctor)* ','? '}'
ParamList ::= '(' DataParam (',' DataParam)* ')'
DataParam ::= Identifier ':' QualifiedName (* e.g. "A : core:Set" *)
Ctor ::= Identifier (* nullary, e.g. "zero" *)
| Identifier '(' CtorArg (',' CtorArg)* ')'
CtorArg ::= CtorArgType (* positional / anonymous *)
| '{' BoundedBinder '}' (* sized binder *)
BoundedBinder::= Identifier (':' QualifiedName)? ('<' QualifiedName)?
(* {j} | {j : Size} | {j < i} | {j : Size < i} *)
CtorArgType ::= QualifiedName (* "Nat" *)
| QualifiedName '(' CtorArgType (',' CtorArgType)* ')' (* "List(A)" *)
CodataDecl ::= 'codata' QualifiedName ParamList? '{' Observation (';' Observation)* ';'? '}'
Observation ::= Identifier ':' TypeExpr
TypeExpr ::= QualifiedName (* "Nat" *)
| QualifiedName '(' TypeExpr (',' TypeExpr)* ')' (* "Stream(A, j)" *)
| TypeExpr '->' TypeExpr (* "A -> B" *)
| '{' BoundedBinder '}' '->' TypeExpr (* "{j < i} -> body" *)

11.1.4. Program and expressions

ProgramDecl ::= 'program' QualifiedName ':' QualifiedName '->' QualifiedName
'{' ProgramAttribute* Expr '}'
ProgramAttribute ::= 'description' '=' StringLit ';'
Expr ::= LetExpr | LambdaExpr | CaseExpr | MatchExpr
| ConstructExpr | CoRecordExpr | ApplyExpr | ProjectExpr
| PairExpr | LiteralExpr | VarExpr
LetExpr ::= 'let' Identifier ':' QualifiedName '=' Expr ';' Expr
LambdaExpr ::= ('\' | 'λ') Identifier '->' Expr
CaseExpr ::= 'case' Expr '{' (Identifier '->' Expr ';')* '}'
MatchExpr ::= 'match' Expr ('returning' QualifiedName)? '{' MatchArm (';' MatchArm)* ';'? '}'
MatchArm ::= Identifier ('(' Identifier (',' Identifier)* ')')? '->' Expr
ConstructExpr::= 'Construct' QualifiedName '{' (QualifiedName '=' Expr (',' QualifiedName '=' Expr)*)? '}'
CoRecordExpr ::= 'corecord' '{' (Identifier '=' Expr ';')* '}'
ApplyExpr ::= QualifiedName '(' (Expr (',' Expr)*)? ')' ('{' ResourceField* '}')?
ProjectExpr ::= Expr '.' QualifiedName
PairExpr ::= '(' Expr ',' Expr ')'
LiteralExpr ::= StringLit | Integer | Float | Boolean
VarExpr ::= Identifier
QualifiedName::= Identifier ':' Identifier
| Identifier (* bare; resolved by context *)

D14 addition: ApplyExpr with a QualifiedName whose IRI classifies through the InstitutionIndex as a Decidable QueryClass dispatches as Exp::NativeDecide (returning a Verdict) — see §9.3. Comorphisms are not callable from ESL expression position under D14; they surface only inside EigenQL FIBER param coercion.

Phase 11h addition: brace-delimited bounded binders in constructor argument and codata observation positions. The three accepted shapes are tabulated in §4.5.

11.2. Keyword reference

Declaration keywords

namespace, class, property, resource, data, codata, program

Class/property body keywords

description, requires, recommends, min_value, max_value, min_length, max_length, pattern, format, allows_only, domain, class_types, element_type

Expression keywords

let, case, match, returning, Construct, map, reduce, corecord

Literal keywords

true, false

11.3. Operator/punctuation reference

TokenUse
=Assignment in let, namespace, fields
->Function-type arrow
\Lambda (ASCII)
λLambda (Unicode)
.Property projection
;Statement / declaration terminator
:Type annotation, qualified-name separator, parent class
,List separator
<Size bound in bounded binders
( )Function call args, parameter telescopes
{ }Block delimiters (declaration bodies, expression blocks, bounded binders)
[ ]Array literals (inside resource fields)

11.4. Compile API

From kernel/src/esl/mod.rs:

pub fn compile(source: &str) -> Result<Vec<Resource>, Vec<EslError>>;
pub fn compile_with_institutions(
source: &str,
index: Arc<InstitutionIndex>,
) -> Result<Vec<Resource>, Vec<EslError>>;
  • compile — base path. Use for ontologies, resources, and programs that do not invoke institution-dispatched function calls.
  • compile_with_institutions — required for programs that use cap:predicate(...) calls referencing a Decidable QueryClass. The InstitutionIndex is derived from the layer chain (InstitutionIndex::from_layer); the compiler consults it to classify the IRI. Without the index, the compile falls through to ordinary component dispatch and fails at runtime with unknown function.

11.5. Kernel capability modes

ModeLayerComponentsInstitutions
Pure
Readyes
Checkoptionalyes
IOyesyesyes

Constructed via the EvalCtx variants. See chapter 8 for the full per-mode behaviour table.

11.7. Source index

All implementation referenced in this guide:

ESL pipeline:

Program parsing (resource → kernel Exp):

Kernel — type theory:

Institutions (D14):

Core / institution ontology:


Return to README.