Lesson 6: Applicatives compose

Contents
  • IO as an Applicative
    • Sorting in IO
  • Functors compose
    • A whole new functor
    • Exercise 1 (MaybeList)
  • Reader plus IO
    • Configurable sorting and IO
    • Exercise 2 (ReaderT)
  • Coming up

In the previous lesson, we examined the function applicative in great detail and introduced the Reader newtype, which is the more common way of using the function applicative.

We will be using Reader again in this lesson, but here we will want to see that it can compose with other applicative functors. The most interesting and common uses of Reader in Haskell are probably Reader composed with IO. So, we’ll start this lesson off by looking at the IO Applicative, working with some short examples, before moving into pairing it with Reader for a longer and more realistic example of the power of applicatives.

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