O'Reilly logo

Haskell Cookbook by Yogesh Sajanikar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Errors and exception handling

We have been looking at Maybe and Either in earlier recipes and used them for conveying error. For example, Nothing :: Maybe a conveys that the evaluation has resulted in an error, and that is how we now have Nothing. Either is more informative than Maybe and conveys more information through its Left constructor.

In this recipe, we will work with three situations: 

  • Working with error and catching it later
  • Working with IO exception and catching it
  • Creating a custom exception, raising it, and catching it

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required