|
1 |
| -# Important notice |
| 1 | +# purescript-eff |
2 | 2 |
|
3 |
| -This module should not yet be depended on, it is for the upcoming 0.7 compiler release. |
| 3 | +[](https://travis-ci.org/purescript/purescript-eff) |
4 | 4 |
|
5 |
| -# Module Documentation |
| 5 | +The `Eff` monad for native effects. For use with compiler version >= 0.7. |
6 | 6 |
|
7 |
| -## Module Control.Monad.Eff |
| 7 | +## Installation |
8 | 8 |
|
9 |
| -#### `Eff` |
10 |
| - |
11 |
| -``` purescript |
12 |
| -data Eff :: # ! -> * -> * |
13 |
| -``` |
14 |
| - |
15 |
| -The `Eff` type constructor is used to represent _native_ effects. |
16 |
| - |
17 |
| -See [Handling Native Effects with the Eff Monad](https://github.com/purescript/purescript/wiki/Handling-Native-Effects-with-the-Eff-Monad) for more details. |
18 |
| - |
19 |
| -The first type parameter is a row of effects which represents the contexts in which a computation can be run, and the second type parameter is the return type. |
20 |
| - |
21 |
| -#### `Pure` |
22 |
| - |
23 |
| -``` purescript |
24 |
| -type Pure a = forall e. Eff e a |
25 |
| -``` |
26 |
| - |
27 |
| -The `Pure` type synonym represents _pure_ computations, i.e. ones in which all effects have been handled. |
28 |
| - |
29 |
| -The `runPure` function can be used to run pure computations and obtain their result. |
30 |
| - |
31 |
| -#### `runPure` |
32 |
| - |
33 |
| -``` purescript |
34 |
| -runPure :: forall a. Pure a -> a |
35 | 9 | ```
|
36 |
| - |
37 |
| -Run a pure computation and return its result. |
38 |
| - |
39 |
| -Note: since this function has a rank-2 type, it may cause problems to apply this function using the `$` operator. The recommended approach |
40 |
| -is to use parentheses instead. |
41 |
| - |
42 |
| -#### `functorEff` |
43 |
| - |
44 |
| -``` purescript |
45 |
| -instance functorEff :: Functor (Eff e) |
| 10 | +bower install purescript-eff |
46 | 11 | ```
|
47 | 12 |
|
| 13 | +## Module documentation |
48 | 14 |
|
49 |
| -#### `applyEff` |
50 |
| - |
51 |
| -``` purescript |
52 |
| -instance applyEff :: Apply (Eff e) |
53 |
| -``` |
54 |
| - |
55 |
| - |
56 |
| -#### `applicativeEff` |
57 |
| - |
58 |
| -``` purescript |
59 |
| -instance applicativeEff :: Applicative (Eff e) |
60 |
| -``` |
61 |
| - |
62 |
| - |
63 |
| -#### `bindEff` |
64 |
| - |
65 |
| -``` purescript |
66 |
| -instance bindEff :: Bind (Eff e) |
67 |
| -``` |
68 |
| - |
69 |
| - |
70 |
| -#### `monadEff` |
71 |
| - |
72 |
| -``` purescript |
73 |
| -instance monadEff :: Monad (Eff e) |
74 |
| -``` |
75 |
| - |
76 |
| - |
77 |
| -#### `untilE` |
78 |
| - |
79 |
| -``` purescript |
80 |
| -untilE :: forall e. Eff e Boolean -> Eff e Unit |
81 |
| -``` |
82 |
| - |
83 |
| -Loop until a condition becomes `true`. |
84 |
| - |
85 |
| -`untilE b` is an effectful computation which repeatedly runs the effectful computation `b`, |
86 |
| -until its return value is `true`. |
87 |
| - |
88 |
| -#### `whileE` |
89 |
| - |
90 |
| -``` purescript |
91 |
| -whileE :: forall e a. Eff e Boolean -> Eff e a -> Eff e Unit |
92 |
| -``` |
93 |
| - |
94 |
| -Loop while a condition is `true`. |
95 |
| - |
96 |
| -`whileE b m` is effectful computation which runs the effectful computation `b`. If its result is |
97 |
| -`true`, it runs the effectful computation `m` and loops. If not, the computation ends. |
98 |
| - |
99 |
| -#### `forE` |
100 |
| - |
101 |
| -``` purescript |
102 |
| -forE :: forall e. Number -> Number -> (Number -> Eff e Unit) -> Eff e Unit |
103 |
| -``` |
104 |
| - |
105 |
| -Loop over a consecutive collection of numbers. |
106 |
| - |
107 |
| -`forE lo hi f` runs the computation returned by the function `f` for each of the inputs |
108 |
| -between `lo` (inclusive) and `hi` (exclusive). |
109 |
| - |
110 |
| -#### `foreachE` |
111 |
| - |
112 |
| -``` purescript |
113 |
| -foreachE :: forall e a. Array a -> (a -> Eff e Unit) -> Eff e Unit |
114 |
| -``` |
115 |
| - |
116 |
| -Loop over an array of values. |
117 |
| - |
118 |
| -`foreach xs f` runs the computation returned by the function `f` for each of the inputs `xs`. |
119 |
| - |
120 |
| - |
121 |
| -## Module Control.Monad.Eff.Unsafe |
122 |
| - |
123 |
| -#### `unsafeInterleaveEff` |
124 |
| - |
125 |
| -``` purescript |
126 |
| -unsafeInterleaveEff :: forall eff1 eff2 a. Eff eff1 a -> Eff eff2 a |
127 |
| -``` |
128 |
| - |
129 |
| -Change the type of an effectful computation, allowing it to be run in another context. |
130 |
| - |
131 |
| -Note: use of this function can result in arbitrary side-effects. |
132 |
| - |
133 |
| - |
134 |
| - |
| 15 | +- [Control.Monad.Eff](docs/Control.Monad.Eff.md) |
| 16 | +- [Control.Monad.Eff.Unsafe](docs/Control.Monad.Eff.Unsafe.md) |
0 commit comments