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


We explored three styles of doing I/O in Haskell: imperative I/O, lazy I/O, and Iteratee I/O. While imperative I/O gave us fine control over resource management and space requirements, it had to be written at a low level of abstraction.

In contrast to this, lazy I/O stood out as elegant and written at a high level of abstraction, giving us great decoupling between producers and consumers. Then we explored the high price we pay for relinquishing control of when side effects occur.

Finally, we found that Iteratee I/O gives us the best of both worlds, fine control over resource management and usage, and written at a very high level of abstraction.

While looking at the three styles, we paid close attention to who was driving evaluation. We looked at the means of decoupling producers and consumers of data and also the extent to which producers and consumers can communicate in the midst of data processing.

In the next chapter, we will focus on patterns for composition with a focus on the fundamental...