-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyntax.sml
94 lines (75 loc) · 1.77 KB
/
syntax.sml
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
structure Syntax = struct
datatype kind = datatype kind
structure TVar :> sig
include ORDERED
val from_string : string -> t
end = struct
type t = string
val compare = String.compare
fun from_string x = x
end
type tvar = TVar.t
type modvar = ModVar.t
type label = Label.t
(* This is necessary due to MLKit's mysterious behavior. *)
structure Path = Path
(* `base` always has the base kind and is free from type variables. *)
datatype base
= Bool
| Int
| Unit
fun show_base Bool = "bool"
| show_base Int = "int"
| show_base Unit = "unit"
datatype lit
= LBool of bool
| LInt of int
| LUnit
type var = string
datatype module
= MVar of modvar
| MEmpty
| MVI of ty
| MVE of exp
| MTI of kind
| MTE of ty
| MInj of label * module
| MProj of module * label
| MUnit of module
| MUI of usig
| MNew of module
| MLink of modvar option * module * module
| MSeal of modvar option * module * module
| MDataSpec of label * ty
| MDataBind of label * ty
and usig
= Import of module * path list
| Export of module * path list
and exp
= EVal of module
| ELit of lit
| EVar of var
| EAbs of (pattern * ty) list * exp
| EApp of exp * exp
| ECon of con * exp * ty
| EMatch of exp * branch * branches
| ETuple of exp list
and pattern
= PVar of var
| PWildcard
| PCon of con * pattern
| PUnit
| PTuple of pattern list
| PBool of bool
and branch = Branch of pattern * exp
and ty
= TTyp of module
| TVar of tvar
| TAbs of tvar * kind * ty
| TApp of ty * ty
| TArrow of ty * ty
| TBase of base
| TSum of ty Sum.t
| TTuple of ty list
withtype branches = branch list
end