You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 4, 2020. It is now read-only.
The `Eff` type constructor is used to represent _native_ effects.
19
+
20
+
See [Handling Native Effects with the Eff Monad](https://github.com/purescript/purescript/wiki/Handling-Native-Effects-with-the-Eff-Monad) for more details.
21
+
22
+
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.
23
+
24
+
#### `Pure`
25
+
26
+
```purescript
27
+
type Pure a = forall e. Eff e a
28
+
```
29
+
30
+
The `Pure` type synonym represents _pure_ computations, i.e. ones in which all effects have been handled.
31
+
32
+
The `runPure` function can be used to run pure computations and obtain their result.
33
+
34
+
#### `runPure`
35
+
36
+
```purescript
37
+
runPure :: forall a. Pure a -> a
38
+
```
39
+
40
+
Run a pure computation and return its result.
41
+
42
+
Note: since this function has a rank-2 type, it may cause problems to apply this function using the `$` operator. The recommended approach
43
+
is to use parentheses instead.
44
+
45
+
#### `untilE`
46
+
47
+
```purescript
48
+
untilE :: forall e. Eff e Boolean -> Eff e Unit
49
+
```
50
+
51
+
Loop until a condition becomes `true`.
52
+
53
+
`untilE b` is an effectful computation which repeatedly runs the effectful computation `b`,
54
+
until its return value is `true`.
55
+
56
+
#### `whileE`
57
+
58
+
```purescript
59
+
whileE :: forall e a. Eff e Boolean -> Eff e a -> Eff e Unit
60
+
```
61
+
62
+
Loop while a condition is `true`.
63
+
64
+
`whileE b m` is effectful computation which runs the effectful computation `b`. If its result is
65
+
`true`, it runs the effectful computation `m` and loops. If not, the computation ends.
66
+
67
+
#### `forE`
68
+
69
+
```purescript
70
+
forE :: forall e. Number -> Number -> (Number -> Eff e Unit) -> Eff e Unit
71
+
```
72
+
73
+
Loop over a consecutive collection of numbers.
74
+
75
+
`forE lo hi f` runs the computation returned by the function `f` for each of the inputs
76
+
between `lo` (inclusive) and `hi` (exclusive).
77
+
78
+
#### `foreachE`
79
+
80
+
```purescript
81
+
foreachE :: forall e a. Array a -> (a -> Eff e Unit) -> Eff e Unit
82
+
```
83
+
84
+
Loop over an array of values.
85
+
86
+
`foreach xs f` runs the computation returned by the function `f` for each of the inputs `xs`.
Copy file name to clipboardExpand all lines: src/Control/Monad/Eff.purs
+7-72Lines changed: 7 additions & 72 deletions
Original file line number
Diff line number
Diff line change
@@ -12,25 +12,9 @@ module Control.Monad.Eff
12
12
-- | 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.
0 commit comments