-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
73 lines (59 loc) · 1.3 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
export type EVariable = {
kind: "EVariable",
name: string
};
export type LiteralInt = {
kind: "LiteralInt",
value: Number
};
export type LiteralString = {
kind: "LiteralString",
value: string,
}
export type LiteralBoolean = {
kind: "LiteralBoolean",
value: Boolean
};
export type ELiteral = {
kind: "ELiteral",
literalValue: LiteralBoolean | LiteralInt | LiteralString
};
export type EApplication = {
kind: "EApplication",
leftExpression: Expression,
rightExpression: Expression
};
export type ELambda = {
kind: "ELambda",
variable: string,
expression: Expression
};
export type ELet = {
kind: "ELet",
name: string,
expression: Expression,
inExpression: Expression
};
export type TVar = {
kind: "TVar",
name: string
};
export type TFunction = {
kind: "TFunction",
from: Type,
to: Type
};
export type TInt = {
kind: "TInt",
};
export type TBool = {
kind: "TBool",
};
export type TString = {
kind: "TString",
};
export type Expression = EVariable | ELiteral | EApplication | ELambda | ELet;
export type Type = TInt | TBool | TString | TVar | TFunction
export type Subsitution = {[key: string]: Type};
export type Scheme = {variables: string[], type: Type};
export type Context = {[key: string]: Scheme};