forked from melsman/contracts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CONTRACTSIG.sig
87 lines (76 loc) · 2.88 KB
/
CONTRACTSIG.sig
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
signature CONTRACTSIG = sig
(* Expressions *)
type 'a num
type 'a exp
type boolE = bool exp
type intE = int num exp
type realE = real num exp
val I : int -> intE
val R : real -> realE
val B : bool -> boolE
val !+! : 'a num exp * 'a num exp -> 'a num exp
val !-! : 'a num exp * 'a num exp -> 'a num exp
val !*! : 'a num exp * 'a num exp -> 'a num exp
val max : 'a num exp * 'a num exp -> 'a num exp
val min : 'a num exp * 'a num exp -> 'a num exp
val !<! : 'a num exp * 'a num exp -> boolE
val !=! : 'a exp * 'a exp -> boolE
val !|! : boolE * boolE -> boolE
val not : boolE -> boolE
val obs : string*int -> 'a exp
val chosenBy : string*int -> boolE
val ifExpr : boolE * 'a exp * 'a exp -> 'a exp
val pair : 'a exp * 'b exp -> ('a*'b) exp
val fst : ('a*'b)exp -> 'a exp
val snd : ('a*'b)exp -> 'b exp
(* Functions *)
val acc : ('a exp -> 'a exp) * int * 'a exp -> 'a exp
(* Environments *)
type date = DateUtil.date
type env
type menv
val emptyEnv : env
val addFix : (string * int * real) * env -> env
val emptyFrom : date -> menv
val addFixing : (string * date * real) * menv -> menv
val addFixings : (string * date) -> real list -> menv -> menv
val promoteEnv : menv -> int -> menv
(* Evaluation *)
val evalR : env -> realE -> real
val evalI : env -> intE -> int
val evalB : env -> boolE -> bool
(* Expression utilities *)
val certainExp : 'a exp -> bool
val simplifyExp : env -> 'a exp -> 'a exp
val ppExp : 'a exp -> string
val eqExp : 'a exp * 'a exp -> bool
val translExp : 'a exp * int -> 'a exp
val hashExp : string list * 'a exp * IntInf.int -> IntInf.int
(* Contracts *)
type party = string
type cur = Currency.cur
type contr
val zero : contr
val transfOne : cur * party * party -> contr
val scale : realE * contr -> contr
val transl : int * contr -> contr
val both : contr * contr -> contr
val iff : boolE * contr * contr -> contr
val checkWithin : boolE * int * contr * contr -> contr
val letc : 'a exp * ('a exp -> contr) -> contr
(* Some derived forms *)
val all : contr list -> contr
val flow : int * realE * cur * party * party -> contr
val dual : contr -> contr
(* Contract utilities *)
val ppContr : contr -> string
val eqContr : contr * contr -> bool
val horizon : contr -> int
(* Managed contracts *)
type mcontr = date * contr
val advance : int -> mcontr -> mcontr
val simplify : menv -> mcontr -> mcontr
type cashflow = date * cur * party * party * bool * realE
val ppCashflows : cashflow list -> string
val cashflows : mcontr -> cashflow list
end