July 2023
Intermediate to advanced
670 pages
17h 13m
English
Now that we’ve seen how to combine different effects using monad transformers, and defined transformers for both ExceptT and StateT, we find ourselves with a bit of a problem: how should we nest them? Consider the parser example we’ve been using throughout this chapter. Should we define one by nesting a StateT inside of an ExceptT, or vice versa? Let’s take a look at the two options to see what impact the choice we have might make.
Let’s start by continuing the pattern we’ve used so far in this chapter, using State as the inner monad and adding ExceptT to give it the ability to handle errors. First, we’ll create a new module, add some imports, and define a type alias for our parser: ...
Read now
Unlock full access