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).

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

O, Monad, Help Me Compose!

  • Anton Antich

摘要

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).