Skip to content
Newer
Older
100644 59 lines (47 sloc) 1.41 KB
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
1 /*
3bb1e06 @OpaOnWindowsNow [doc] stdlib,reference,mutable: advise the use of Mutable instead of …
OpaOnWindowsNow authored Feb 16, 2012
2 Copyright © 2011, 2012 MLstate
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 */
18
62c92c3 [doc] review: Review of stdlib.core
Guillem Rieu authored Jun 17, 2011
19
20 /**
21 * {1 Types defined in this module}
22 */
23
3bb1e06 @OpaOnWindowsNow [doc] stdlib,reference,mutable: advise the use of Mutable instead of …
OpaOnWindowsNow authored Feb 16, 2012
24 /**
25 * The type of mutable element.
26 * @param 'a The type contained in the element.
27 * get returns the content of the mutable element.
28 * set changes the content of the mutable element.
29 */
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
30 type Mutable.t('a) = {get: -> 'a; set: 'a -> void}
3bb1e06 @OpaOnWindowsNow [doc] stdlib,reference,mutable: advise the use of Mutable instead of …
OpaOnWindowsNow authored Feb 16, 2012
31
32 /**
33 * {1 About this module}
34 *
35 * It provides a way to have a mutable state.
36 *
37 * e.g.
38 *
39 * state = Mutable.create("initial state content")
40 * println(state.get())
41 * state.set("new state content")
42 *
43 */
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
44 Mutable =
45 {{
46 make(init:'a): Mutable.t('a) =
47 r = Reference.create(init)
48 {{
49 get() = Reference.get(r)
50 set(x)= Reference.set(r, x)
51 }}
52
53 }}
54
55 @opacapi
56 Mutable_make = Mutable.make
3bb1e06 @OpaOnWindowsNow [doc] stdlib,reference,mutable: advise the use of Mutable instead of …
OpaOnWindowsNow authored Feb 16, 2012
57
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
58 @opacapi Mutable_set(mutable,v) : Mutable.t('a) = mutable.set(v)
Something went wrong with that request. Please try again.