this repo has no description
1* Exceptions
2
3Pure functions are lazy by default, which means that we don't know when they will be evaluated and that it really shouldn't matter.
4However, once pure functions start throwing exceptions, it matters when they are evaluated.
5That's why we can only catch exceptions thrown from pure functions in the I/O part of our code.
6And that's bad because we want to keep the I/O part as small as possible.
7However, if we don't catch them in the I/O part of our code, our program crashes.
8The solution? Don't mix exceptions and pure code.
9Take advantage of Haskell's powerful type system and use types like *Either* and *Maybe* to represent results that may have failed.
10
11Let's make an example using *catch* to treat errors when opening a file that does not exists.
12
13[[file:files/countLinesException.hs][Example of exception handling]]