Contents
ReaderIO
revisited- Coerce
- Compose yourself
- Exercise 1
- Deriving via
- Exercise 2
- Coming up
Previously, we looked at how to combine the Reader
type with IO
into one applicative functor that has the flavor of both of its parent applicatives. This lesson will extend the theme of the previous lesson, picking up where it left off and then introducing another newtype called Compose
that generalizes this idea that any two functors or applicative functors can, well, compose.
ReaderIO
revisited
When we wrote the Applicative
instance for ReaderIO
, we made use of the built-in Applicative
instance for IO
but manipulated the Reader
parts of it ourselves, explicitly passing around the env
like packhorses.