Skip to content

Commit 9d9c141

Browse files
author
Yoav
authored
Fixed strange wording (learnyouahaskell#29)
1 parent 56a33db commit 9d9c141

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/input-and-output.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,7 @@ <h1>Input and Output</h1>
12461246
| otherwise = ioError e
12471247
</pre>
12481248
<p>Everything stays the same except the handler, which we modified to only catch a certain group of I/O exceptions. Here we used two new functions from <span class="fixed">System.IO.Error</span> &mdash; <span class="label function">isDoesNotExistError</span> and <span class="label function">ioError</span>. <span class="fixed">isDoesNotExistError</span> is a predicate over <span class="fixed">IOError</span>s, which means that it's a function that takes an <span class="fixed">IOError</span> and returns a <span class="fixed">True</span> or <span class="fixed">False</span>, meaning it has a type of <span class="fixed">isDoesNotExistError :: IOError -&gt; Bool</span>. We use it on the exception that gets passed to our handler to see if it's an error caused by a file not existing. We use <a href="syntax-in-functions.html#guards-guards">guard</a> syntax here, but we could have also used an <i>if else</i>. If it's not caused by a file not existing, we re-throw the exception that was passed by the handler with the <span class="fixed">ioError</span> function. It has a type of <span class="fixed">ioError :: IOException -&gt; IO a</span>, so it takes an <span class="fixed">IOError</span> and produces an I/O action that will throw it. The I/O action has a type of <span class="fixed">IO a</span>, because it never actually yields a result, so it can act as <span class="fixed">IO <i>anything</i></span>.</p>
1249-
<p>So the exception thrown in the <span class="fixed">toTry</span> I/O action that we glued together with a <i>do</i> block isn't caused by a file existing, <span class="fixed">toTry `catch` handler</span> will catch that and then re-throw it. Pretty cool, huh?</p>
1249+
<p>So if the exception thrown in the <span class="fixed">toTry</span> I/O action that we glued together with a <i>do</i> block isn't caused by a file not existing, <span class="fixed">toTry `catch` handler</span> will catch that and then re-throw it. Pretty cool, huh?</p>
12501250
<p>There are several predicates that act on <span class="fixed">IOError</span> and if a guard doesn't evaluate to <span class="fixed">True</span>, evaluation falls through to the next guard. The predicates that act on <span class="fixed">IOError</span> are:</p>
12511251
<ul>
12521252
<li><span class="function label">isAlreadyExistsError</span></li>

0 commit comments

Comments
 (0)