location_city Sydney schedule May 23rd 10:30 - 11:00 AM AEST place Green Room people 150 Interested

Handling errors in a principled manner is an important aspect of writing production code. Drawing on our experience of writing production systems in Haskell, we believe that for a large class of problems, using the EitherT monad transformer is a simple and effective pattern to handle errors. We suggest that often, several mechanisms for error handling appear in code bases (including exceptions and the use of free monads) and that it will be of interest to intermediate Haskellers to see a principled approach that only uses EitherT to accomplish this.


Outline/Structure of the Talk

  1. Describe the need to have a principled approach to handling errors in production code.

  2. Provide an overview of EitherT by building it up from `Either` and `IO (Either a b)`

  3. Walk through the details of writing a CLI application that analyses a file expected to contain structured data. This will demonstrate how to compose different kinds of failure (i.e. IO and parsing failures) with EitherT, as well as how to lift pure, partial and side-effecting functions into EitherT.

  4. Describe our approach to testing code written in this manner.

  5. Reinforce the point that this approach needs to be coupled with other principles, such as avoiding partial functions.

  6. Describe limitations and drawbacks of the EitherT approach.

  7. Compare the EitherT approach with other common patterns, such as free monads and using exceptions for control.

Learning Outcome

  • A pattern for writing production code using EitherT for handling errors.

  • An appreciation of the value of taking a principled approach to error handling.

  • A better understanding of monad transformers.

Target Audience

Intermediate functional programmers curious to see a type-driven approach to handling errors in production code.

Prerequisites for Attendees

None, however familiarity with typed functional programming and Haskell syntax will be helpful.



schedule Submitted 5 years ago