42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
/**
|
||
* Terms e ::= x | () | λx. e | e e | (e : A)
|
||
* Types A, B, C ::= 1 | α | ^α | ∀α. A | A → B
|
||
* Monotypes τ, σ ::= 1 | α | ^α | τ → σ
|
||
* Contexts Γ, ∆, Θ ::= · | Γ, α | Γ, x : A
|
||
* | Γ, ^α | Γ, ^α = τ | Γ, I^α
|
||
* Complete Contexts Ω ::= · | Ω, α | Ω, x : A
|
||
* | Ω, ^α = τ | Ω, I^
|
||
*/
|
||
|
||
export type Term =
|
||
| { kind: "var"; name: string }
|
||
| { kind: "unit" }
|
||
| { kind: "lambda"; name: string; body: Term }
|
||
| { kind: "app"; func: Term; arg: Term }
|
||
| { kind: "annot"; term: Term; type: Type };
|
||
|
||
export type Type =
|
||
| { kind: "unit" }
|
||
| { kind: "var"; name: string }
|
||
| { kind: "existential"; name: string }
|
||
| { kind: "poly"; name: string; type: Type }
|
||
| { kind: "arrow"; input: Type; output: Type };
|
||
|
||
export type Monotype =
|
||
| { kind: "unit" }
|
||
| { kind: "var"; name: string }
|
||
| { kind: "existential"; name: string }
|
||
| { kind: "arrow"; input: Monotype; output: Monotype };
|
||
|
||
export type ContextEntry =
|
||
| { kind: "typeVar"; name: string }
|
||
| { kind: "termAnnot"; name: string; type: Type }
|
||
| { kind: "existentialVar"; name: string }
|
||
| { kind: "existentialSolved"; name: string; type: Monotype }
|
||
| { kind: "marker"; name: string };
|
||
|
||
export type CompleteContextEntry =
|
||
| { kind: "typeVar"; name: string }
|
||
| { kind: "termAnnot"; name: string; type: Type }
|
||
| { kind: "existentialSolved"; name: string; type: Monotype }
|
||
| { kind: "marker"; name: string };
|