Book Image

Haskell Design Patterns

By : Tikhon Jelvis, Ryan Lemmer
Book Image

Haskell Design Patterns

By: Tikhon Jelvis, Ryan Lemmer

Overview of this book

Design patterns and idioms can widen our perspective by showing us where to look, what to look at, and ultimately how to see what we are looking at. At their best, patterns are a shorthand method of communicating better ways to code (writing less, more maintainable, and more efficient code) This book starts with Haskell 98 and through the lens of patterns and idioms investigates the key advances and programming styles that together make "modern Haskell". Your journey begins with the three pillars of Haskell. Then you'll experience the problem with Lazy I/O, together with a solution. You'll also trace the hierarchy formed by Functor, Applicative, Arrow, and Monad. Next you'll explore how Fold and Map are generalized by Foldable and Traversable, which in turn is unified in a broader context by functional Lenses. You'll delve more deeply into the Type system, which will prepare you for an overview of Generic programming. In conclusion you go to the edge of Haskell by investigating the Kind system and how this relates to Dependently-typed programming
Table of Contents (14 chapters)

Summary


This chapter focused on ways of composing functions and types. We saw that Functor, Applicative, Arrow and Monad all fall on a spectrum of generality, with Monad being the most powerful type.

We also found how different the historical development of these types were from their natural order in the abstraction hierarchy. This explained the redundancies in type-class methods across these types.

In the next chapter, we'll explore how folding and traversing (something we're very used to when working with lists) can be generalized to Applicative and Monad. To get to the heart of folding, we'll take a good look at the very simple and powerful Monoid type and see how intricately it is related to folding over data types.

We'll also learn about functional lenses and see how they relate to traversing ad hoc data structures.