|
1 | | -# Module Documentation |
| 1 | +# purescript-refs |
2 | 2 |
|
3 | | -## Module Control.Monad.Eff.Ref |
| 3 | +[](https://travis-ci.org/purescript/purescript-refs) |
4 | 4 |
|
| 5 | +Mutable value references. |
5 | 6 |
|
6 | | -This module defines an effect and actions for working with |
7 | | -global mutable variables. |
| 7 | +## Installation |
8 | 8 |
|
9 | | -_Note_: The `Control.Monad.ST` provides a _safe_ alternative |
10 | | -to global mutable variables when mutation is restricted to a |
11 | | -local scope. |
12 | | - |
13 | | -#### `REF` |
14 | | - |
15 | | -``` purescript |
16 | | -data REF :: ! |
17 | 9 | ``` |
18 | | - |
19 | | -The effect associated with the use of global mutable variables. |
20 | | - |
21 | | -#### `Ref` |
22 | | - |
23 | | -``` purescript |
24 | | -data Ref :: * -> * |
25 | | -``` |
26 | | - |
27 | | -A value of type `Ref a` represents a mutable reference |
28 | | -which holds a value of type `a`. |
29 | | - |
30 | | -#### `newRef` |
31 | | - |
32 | | -``` purescript |
33 | | -newRef :: forall s r. s -> Eff (ref :: REF | r) (Ref s) |
34 | | -``` |
35 | | - |
36 | | -Create a new mutable reference containing the specified value. |
37 | | - |
38 | | -#### `readRef` |
39 | | - |
40 | | -``` purescript |
41 | | -readRef :: forall s r. Ref s -> Eff (ref :: REF | r) s |
42 | | -``` |
43 | | - |
44 | | -Read the current value of a mutable reference |
45 | | - |
46 | | -#### `modifyRef'` |
47 | | - |
48 | | -``` purescript |
49 | | -modifyRef' :: forall s b r. Ref s -> (s -> { value :: b, state :: s }) -> Eff (ref :: REF | r) b |
50 | | -``` |
51 | | - |
52 | | -Update the value of a mutable reference by applying a function |
53 | | -to the current value. |
54 | | - |
55 | | -#### `modifyRef` |
56 | | - |
57 | | -``` purescript |
58 | | -modifyRef :: forall s r. Ref s -> (s -> s) -> Eff (ref :: REF | r) Unit |
59 | | -``` |
60 | | - |
61 | | -Update the value of a mutable reference by applying a function |
62 | | -to the current value. |
63 | | - |
64 | | -#### `writeRef` |
65 | | - |
66 | | -``` purescript |
67 | | -writeRef :: forall s r. Ref s -> s -> Eff (ref :: REF | r) Unit |
68 | | -``` |
69 | | - |
70 | | -Update the value of a mutable reference to the specified value. |
71 | | - |
72 | | - |
73 | | -## Module Control.Monad.Eff.Ref.Unsafe |
74 | | - |
75 | | - |
76 | | -Unsafe functions for working with mutable references. |
77 | | - |
78 | | -#### `unsafeRunRef` |
79 | | - |
80 | | -``` purescript |
81 | | -unsafeRunRef :: forall eff a. Eff (ref :: REF | eff) a -> Eff eff a |
| 10 | +bower install purescript-refs |
82 | 11 | ``` |
83 | 12 |
|
84 | | -This handler function unsafely removes the `Ref` effect from an |
85 | | -effectful action. |
| 13 | +## Module documentation |
86 | 14 |
|
87 | | -This function might be used when it is impossible to prove to the |
88 | | -typechecker that a particular mutable reference does not escape |
89 | | -its scope. |
| 15 | +- [Control.Monad.Eff.Ref](docs/Control.Monad.Eff.Ref.md) |
| 16 | +- [Control.Monad.Eff.Ref.Unsafe](docs/Control.Monad.Eff.Ref.Unsafe.md) |
0 commit comments