O, Monad, Help Me Compose!
摘要
By now, you should have a basic intuition on how various Haskell abstractions arise. We have concrete types, such as Int and Char; we have "type functions" that create new types from other types, such as Maybe a and List a. We have typeclasses that capture internal types' structure as well as relations between them. In the real-world application, that is where you should always start : design your types, then try to capture relations between them, and see whether they correspond to some of the known abstractions, such as Monoid, Functor, or Applicative. Once you have, the only thing left is decomposing the problem into smaller pieces and solving it by composing functions together, just like in the simplified picture from Chapter 1 (Figure 6-1).