Handling Errors in Other Computations
In the last section, we looked at how to add error handling to a parser that we built using State, but as you’ve seen throughout this book the problem of dealing with error handling in some sort of computation is common. Another example where you’ve already had first-hand experience with this is in handling failures inside of IO actions. We’ve previously handled errors inside of IO actions by raising exceptions using ioError. Although we’ve managed to get by with IO exceptions, they have a couple of problems. First, we’re risking errors caused by unhandled exceptions. We can certainly argue that developers should be responsible and handle exceptions appropriately but there’s nothing to force us to catch ...
Get Effective Haskell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.