Lesson 7: The Compose newtype


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.

Sign up for access to the full page, plus the complete archive and all the latest content.