Skip to content

Latest commit

 

History

History
78 lines (72 loc) · 1.25 KB

ch22.adoc

File metadata and controls

78 lines (72 loc) · 1.25 KB

22 Reader

22.2 A new beginning

link:ch22_22.2_1.hs[role=include]

Short Exercise

link:ch22_22.2_2.hs[role=include]

22.5 But uh, Reader?

Exercise

It is correct, but cannot make it compile. Even after installing mtl package, I get Not in scope: data constructor 'Reader'.

So i added the newtype Reader definition by hand. I tought this is generally available

link:ch22_22.5_1.hs[role=include]

22.6 Functions have an Applicative too

Exercise

  1. myLiftA2, I feel like I am cheating.

    link:ch22_22.6_1.hs[role=include]
  2. asks

    link:ch22_22.6_2.hs[role=include]
  3. Applicative, had to also make Functor for it :|

    link:ch22_22.6_3.hs[role=include]
  4. I would explain it as implementation of Reader.

    link:ch22_22.6_4.hs[role=include]

22.7 The Monad of functions

Exercise

  1. Reader Monad

    link:ch22_22.7_1.hs[role=include]
  2. Is this right? It compiles and looks similar to Applicative.

    link:ch22_22.7_2.hs[role=include]

22.11 Chapter Exercises

A warm-up stretch

ok…​..

link:ch22_22.11_1.hs[role=include]

Rewriting Shawty

use ReaderT, I will come back later

link:ch22_22.11_2.hs[role=include]