Lesson 38. Errors in Haskell and the Either type

After reading lesson 38, you’ll be able to

  • Throw errors by using the error function
  • Understand the dangers of throwing errors
  • Use Maybe as a method for handling errors
  • Handle more sophisticated errors with the Either type

Most of what makes Haskell so powerful is based on the language being safe, predictable, and reliable. Although Haskell reduces or eliminates many problems, errors are an unavoidable part of real-world programming. In this lesson, you’ll learn how to think about handling errors in Haskell. The traditional approach of throwing an exception is frowned upon in Haskell, as this makes it easy to have runtime errors the compiler can’t catch. Although Haskell does allow you to ...

Get Get Programming with 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.