forked from melsman/contracts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ContractBase.sml
36 lines (33 loc) · 1.16 KB
/
ContractBase.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
structure ContractBase = struct
type var0 = string
datatype exp0 = I of int
| R of real
| B of bool
| V of var0
| BinOp of string * exp0 * exp0
| UnOp of string * exp0
| Obs of string * int (* Obs(s,i): the value of s in i days; negative
* values refer to the past... *)
| ChosenBy of string * int (* label(incl party) and time *)
| Iff of exp0 * exp0 * exp0
| Pair of exp0 * exp0
| Fst of exp0
| Snd of exp0
| Acc of (var0*exp0) * int * exp0 (* Acc(f,i,a) = f/i(...(f/2(f/1(a)))) *)
local open Currency
in
type party = string
datatype contr =
Zero
| TransfOne of cur * party * party
| Scale of exp0 * contr
| Transl of int * contr
| Both of contr * contr
| If of exp0 * contr * contr
| CheckWithin of exp0 * int * contr * contr
(* if cond : boolE becomes true within time: intE then contract 1 in effect.
otherwise (time expired, always false) contract 2 in effect
*)
| Let of var0 * exp0 * contr
end
end