Import Upstream version 20180207
[hcoop/debian/mlton.git] / lib / mlton / basic / property.sig
1 (* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
2 * Jagannathan, and Stephen Weeks.
3 *
4 * MLton is released under a BSD-style license.
5 * See the file MLton-LICENSE for details.
6 *)
7
8 signature PROPERTY =
9 sig
10 structure Plist: PROPERTY_LIST
11
12 type ('sym, 'val) init
13
14 val initConst: 'val -> ('sym, 'val) init
15 val initFun: ('sym -> 'val) -> ('sym, 'val) init
16 val initRaise: string * ('sym -> Layout.t) -> ('sym, 'val) init
17 val initRec: ('sym * ('sym -> 'val) -> 'val) -> ('sym, 'val) init
18
19 val destGet:
20 ('sym -> Plist.t) * ('sym, 'val) init
21 -> {
22 destroy: unit -> unit,
23 get: 'sym -> 'val
24 }
25
26 val destGetSet:
27 ('sym -> Plist.t) * ('sym, 'val) init
28 -> {
29 destroy: unit -> unit,
30 get: 'sym -> 'val,
31 set: 'sym * 'val -> unit
32 }
33
34 val destGetSetOnce:
35 ('sym -> Plist.t) * ('sym, 'val) init
36 -> {
37 get: 'sym -> 'val,
38 set: 'sym * 'val -> unit,
39 destroy: unit -> unit
40 }
41
42 (* For all of the rem functions, it is OK if the property isn't there. *)
43
44 val get:
45 ('sym -> Plist.t) * ('sym, 'val) init
46 -> {
47 get: 'sym -> 'val,
48 rem: 'sym -> unit
49 }
50
51 val getSet:
52 ('sym -> Plist.t) * ('sym, 'val) init
53 -> {
54 get: 'sym -> 'val,
55 rem: 'sym -> unit,
56 set: 'sym * 'val -> unit
57 }
58
59 (* Property can only be set or initialized once. *)
60 val getSetOnce:
61 ('sym -> Plist.t) * ('sym, 'val) init
62 -> {
63 get: 'sym -> 'val,
64 rem: 'sym -> unit,
65 set: 'sym * 'val -> unit
66 }
67
68 end