Haskell Design Patterns

Ryan Lemmer

商品描述

Take your Haskell and functional programming skills to the next level by exploring new idioms and design patterns

About This Book

  • Explore Haskell on a higher level through idioms and patterns
  • Get an in-depth look into the three strongholds of Haskell: higher-order functions, the Type system, and Lazy evaluation
  • Expand your understanding of Haskell and functional programming, one line of executable code at a time

Who This Book Is For

If you're a Haskell programmer with a firm grasp of the basics and ready to move more deeply into modern idiomatic Haskell programming, then this book is for you.

What You Will Learn

  • Understand the relationship between the “Gang of Four” OOP Design Patterns and Haskell
  • Try out three ways of Streaming I/O: imperative, Lazy, and Iteratee based
  • Explore the pervasive pattern of Composition: from function composition through to high-level composition with Lenses
  • Synthesize Functor, Applicative, Arrow and Monad in a single conceptual framework
  • Follow the grand arc of Fold and Map on lists all the way to their culmination in Lenses and Generic Programming
  • Get a taste of Type-level programming in Haskell and how this relates to dependently-typed programming
  • Retrace the evolution, one key language extension at a time, of the Haskell Type and Kind systems
  • Place the elements of modern Haskell in a historical framework

In Detail

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.

Style and approach

Using short pieces of executable code, this guide gradually explores the broad pattern landscape of modern Haskell. Ideas are presented in their historical context and arrived at through intuitive derivations, always with a focus on the problems they solve.

商品描述(中文翻譯)

將你的 Haskell 和函數式編程技能提升到更高的水平,通過探索新的慣用語和設計模式。

關於本書
- 通過慣用語和模式在更高層次上探索 Haskell
- 深入研究 Haskell 的三個支柱:高階函數、類型系統和惰性求值
- 逐行擴展你對 Haskell 和函數式編程的理解

本書適合對 Haskell 基礎知識有牢固掌握並準備深入了解現代慣用 Haskell 編程的 Haskell 程序員。

你將學到什麼
- 理解“四人幫”面向對象設計模式和 Haskell 之間的關係
- 嘗試三種流式 I/O 的方式:命令式、惰性和迭代器
- 探索組合的普遍模式:從函數組合到使用 Lenses 的高級組合
- 在單一概念框架中綜合 Functor、Applicative、Arrow 和 Monad
- 從列表的 Fold 和 Map 的整個演變過程一直到它們在 Lenses 和泛型編程中的結合
- 了解 Haskell 中的類型級編程以及它與依賴類型編程的關係
- 逐步回顧 Haskell 類型和類型系統的演進,一次引入一個關鍵的語言擴展
- 將現代 Haskell 的元素放入歷史框架中

詳細內容
設計模式和慣用語可以通過向我們展示在哪裡尋找、如何觀察以及最終如何看待我們所觀察的內容,從而擴大我們的視野。在最好的情況下,模式是一種簡潔的方法,用於傳達更好的編碼方式(寫更少、更易維護和更高效的代碼)。

本書從 Haskell 98 開始,通過模式和慣用語的視角,探討了一起構成“現代 Haskell”的關鍵進展和編程風格。你的旅程從 Haskell 的三個支柱開始。然後,你將體驗到惰性 I/O 的問題以及解決方案。你還將追蹤 Functor、Applicative、Arrow 和 Monad 形成的層次結構。接下來,你將探索 Fold 和 Map 如何通過 Foldable 和 Traversable 進行泛化,而這又在更廣泛的上下文中通過函數 Lenses 進行統一。你將更深入地研究類型系統,這將為你提供泛型編程的概述。最後,你將探索 Haskell 的邊界,研究類型系統如何與依賴類型編程相關聯。

風格和方法
本指南使用短小的可執行代碼逐步探索現代 Haskell 的廣泛模式。這些想法以其歷史背景呈現,並通過直觀的推導得出,始終關注它們解決的問題。