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
Copy file name to clipboardExpand all lines: _site/learn/eff/index.html
+5-5
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@ <h2>Handling Native Effects with the Eff Monad</h2>
55
55
<li>Writing/reading to/from local storage</li>
56
56
</ul>
57
57
<h4id="the-eff-monad">The Eff Monad</h4>
58
-
<p>PureScript’s <code>purescript-eff</code> package defines a monad called <code>Eff</code>, which is used to handle native effects. The goal of the <code>Eff</code> monad is to provide a typed API for effectful computations, while at the same time generating efficient Javascript.</p>
58
+
<p>PureScript’s <ahref="https://pursuit.purescript.org/packages/purescript-eff/"><code>purescript-eff</code></a> package defines a monad called <code>Eff</code>, which is used to handle native effects. The goal of the <code>Eff</code> monad is to provide a typed API for effectful computations, while at the same time generating efficient Javascript.</p>
<p>This example requires the <code>purescript-console</code> and <code>purescript-random</code> dependencies to be installed:</p>
71
+
<p>This example requires the <ahref="https://pursuit.purescript.org/packages/purescript-console/"><code>purescript-console</code></a> and <ahref="https://pursuit.purescript.org/packages/purescript-random/"><code>purescript-random</code></a> dependencies to be installed:</p>
<h4id="handlers-and-actions">Handlers and Actions</h4>
123
123
<p>Rows of effects can also appear on the left-hand side of a function arrow. This is what differentiates actions like <code>print</code> and <code>random</code> from effect <em>handlers</em>.</p>
124
124
<p>While actions <em>add</em> to the set of required effects, a handler <code>subtracts</code> effects from the set.</p>
125
-
<p>Consider <code>catchException</code> from the <code>purescript-exceptions</code> package:</p>
125
+
<p>Consider <code>catchException</code> from the <ahref="https://pursuit.purescript.org/packages/purescript-exceptions/"><code>purescript-exceptions</code></a> package:</p>
126
126
<divclass="sourceCode"><preclass="sourceCode haskell"><codeclass="sourceCode haskell"><spanclass="ot">catchException ::</span> forall a e<spanclass="fu">.</span> (<spanclass="dt">Error</span><spanclass="ot">-></span><spanclass="dt">Eff</span> e a) <spanclass="ot">-></span>
127
127
<spanclass="dt">Eff</span> (<spanclass="ot">err ::</span><spanclass="dt">EXCEPTION</span><spanclass="fu">|</span> e) a <spanclass="ot">-></span>
128
128
<spanclass="dt">Eff</span> e a</code></pre></div>
@@ -138,10 +138,10 @@ <h4 id="handlers-and-actions">Handlers and Actions</h4>
divide _ <spanclass="dv">0</span><spanclass="fu">=</span>throwError<spanclass="st">"Division by zero"</span>
144
+
divide _ <spanclass="dv">0</span><spanclass="fu">=</span>throw<spanclass="st">"Division by zero"</span>
145
145
divide n m <spanclass="fu">=</span> return (n <spanclass="fu">/</span> m)</code></pre></div>
146
146
<p>If we have already defined this function, we can use the <code>runPure</code> and <code>catchException</code> handlers to define a version of <code>divide</code> which reports its errors using <code>Either</code>:</p>
0 commit comments