The examples in this lecture run in GHC <= version 7.8. If you have GHC >= version 7.10, you need some extra lines — see the source code — to make it work. However, you do not need to understand them. We will cover the reason for such extra lines in the next lecture.


Some programming features in imperative languages

What about in Haskell? (Pure functional language)

Handling errors explicitly


Side-effects & pure functional programming

Imperative programming Pure functional programming
Error handling Plumbing (check if any subcomputation has failed)
Logging Plumbing (consider subcomputations' logs)


Construction of programs

Error handling

Error handling in the interpreter


Enter Monads

Revised interpreters

Monads and EDSL?

Deep embedding for error handling monad

Stateful computations

Implementation (shallow embedding)

Monads so far