-
Notifications
You must be signed in to change notification settings - Fork 5
/
Module.fm
34 lines (27 loc) · 991 Bytes
/
Module.fm
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
Module: Type
Map(Export)
Module.new: Module
Map.new<Export>
Module.type(key: String, mod: Module): Type
case Map.get<Export>(String.to_bits(key), mod) as got:
| Unit;
| Export.T(got.value);
Module.get(key: String, mod: Module): Module.type(key, mod)
case Map.get<Export>(String.to_bits(key), mod) as got:
| Unit.new;
| Export.value(got.value);
: case got.self:
| Unit;
| Export.T(got.self.value);;
Module.set(key: String, val: Export, mod: Module): Module
Map.set<Export>(String.to_bits(key), val, mod)
Module.from(defs: List(Pair(String, Export))): Module
Map.from_list<,>(String.to_bits,defs)
Module.to_list(m : Module) : List(Pair(Bits,Type))
def f = ((p) get x y = p Pair.new<Bits,Type>(x,Export.T(y)))
:: Pair(Bits,Export) -> Pair(Bits,Type)
List.map<,>(f, Map.to_list<>(m))
Module.Row(field: String, T: Type, m: Module) : Type
case Map.get<Export>(String.to_bits(field),m) as got:
| Empty;
| Equal(Type,T,Export.T(got.value));