-
Notifications
You must be signed in to change notification settings - Fork 2
/
stdTypes.star
50 lines (40 loc) · 1.3 KB
/
stdTypes.star
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
stdTypes is package{
private import canonical
private import types
private import parseType
private import astUtils
private import good
private import location
def booleanType is iType("boolean")
def stdDict is valof {
var D := dict{
names = dictionary of []
types = dictionary of [
"integer" -> typeIs{loc=missing;tipe=iType("integer")},
"float" -> typeIs{loc=missing;tipe=iType("float")},
"string" -> typeIs{loc=missing;tipe=iType("string")}
]
contracts = dictionary of []
implementations = dictionary of []
outer = none
}
D := stdType("type boolean is true or false",D)
D := stdType("type option of t is none or some(t)",D)
D := stdFun("=","for all t such that (t,t)=>boolean",D)
-- D := stdContract("contract equality over t is { (=) has type (t,t)=>boolean; (!=) has type (t,t)=>boolean }",D)
-- logMsg(info,"stddict is $D")
valis D
}
private
fun stdType(S,D) is valof parseAlgebraicType(parseString(S),D)
private
fun stdContract(S,D) is valof{
def (Nm,entry) is valof parseContract(parseString(S),D)
valis declareContract(D,Nm,entry)
}
private
fun stdFun(Nm,S,D) is valof {
def Tp is valof parseType(parseString(S),D)
valis defineVar(D,Nm,cVar{loc=missing;name=Nm;tipe=Tp})
}
}