Haskell Design Patterns

Take Your Haskell and Functional Programming Skills to the Next Level by Exploring New Idioms and Design Patterns
 
 
Packt Publishing
  • 1. Auflage
  • |
  • erschienen am 6. November 2015
  • |
  • 166 Seiten
 
E-Book | ePUB mit Adobe-DRM | Systemvoraussetzungen
E-Book | PDF mit Adobe-DRM | Systemvoraussetzungen
978-1-78398-873-0 (ISBN)
 
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.
 
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.
  • Englisch
  • Birmingham
  • |
  • Großbritannien
978-1-78398-873-0 (9781783988730)

weitere Ausgaben werden ermittelt
Ryan Lemmer is software maker, coach, and strategic advisor based in Cape Town.
With a background in mathematics and computer science and 20 years of developing software in the trenches, Ryan remains inspired and humbled by the process of creating and evolving software.
Ryan is a polyglot programmer, who prefers to think in Haskell.
He loves to learn and facilitate learning for others.
Ryan Lemmer is software maker, coach, and strategic advisor based in Cape Town.
With a background in mathematics and computer science and 20 years of developing software in the trenches, Ryan remains inspired and humbled by the process of creating and evolving software.
Ryan is a polyglot programmer, who prefers to think in Haskell.
He loves to learn and facilitate learning for others.
  • Cover
  • Copyright
  • Credits
  • About the Author
  • About the Reviewer
  • www.PacktPub.com
  • Table of Contents
  • Preface
  • Chapter 1: Functional Patterns - the Building Blocks
  • Higher-order functions
  • Functions as first-class citizens
  • Composing functions
  • Currying functions
  • Currying and composability
  • Decoupling with currying
  • Recursion
  • Non-tail recursion
  • Tail recursion
  • Folding abstracts recursion
  • Types, pattern matching, and polymorphism
  • Algebraic types and pattern matching
  • Recursive types
  • Polymorphism
  • Parametric polymorphism
  • Ad-hoc polymorphism
  • Functions, types, and patterns
  • The strategy pattern
  • The template pattern
  • The iterator pattern
  • Decoupling behavior and modularizing code
  • Lazy evaluation
  • Streams
  • Modeling change with streams
  • Lazy evil
  • Monads
  • Composing monads and structuring programs
  • Summary
  • Chapter 2: Patterns for I/O
  • I/O as a first class citizen
  • I/O as a functor, applicative, and monad
  • Imperative I/O
  • Lazy I/O
  • The problems with lazy I/O
  • Resource management with bracket
  • Iteratee I/O
  • Iteratee
  • Enumerator
  • Generalized iteratees, enumerators, and enumeratees
  • The iteratee I/O libraries
  • Comparing the three styles of I/O
  • Summary
  • Chapter 3: Patterns of Composition
  • Functor
  • Applicative functor
  • Monad
  • Monad as functor
  • Monad as applicative
  • Sequencing actions with monad and applicative
  • Monads and the bind chain
  • Composing with monads
  • Monad transformers
  • IO in monad stacks
  • Sequence of stack composition
  • Arrows
  • Implementing an arrow
  • Arrow operators
  • Kleisli arrows and monad arrows
  • Why arrows?
  • Summary
  • Chapter 4: Patterns of Folding and Traversing
  • Folding over lists
  • Folding with monadic functions
  • Folding with monoids
  • Foldable
  • Mapping over lists
  • Traversable
  • A Traversable Tree
  • The traversal and the Iterator pattern
  • Modernizing Haskell 98
  • Lenses
  • Deriving Lens
  • Writing a Lens
  • Composable getters and setters
  • Lens Traversal
  • Lens.Fold
  • The Lens library
  • Summary
  • Chapter 5: Patterns of Type Abstraction
  • Abstracting function types: RankNTypes
  • Abstracting datatypes
  • Universal quantification
  • Existential quantification and abstract datatypes
  • Phantom types
  • Generalized algebraic datatypes
  • Typecase pattern
  • Dynamic types
  • Heterogeneous lists
  • Abstracting type-classes
  • Multiparameter type-classes
  • Functional dependencies
  • Summary
  • Chapter 6: Patterns of Generic Programming
  • Patterns of generic programming
  • Patterns 1 and 2 - functions
  • Pattern 3 - polymorphic types and functions
  • Pattern 4 - type-class polymorphism
  • Pattern 5 - meta-programming
  • The Derivable type-classes
  • Generalized newtype deriving
  • Pattern 6 - type laws
  • Pattern 7 - datatype generic programming
  • The sum of products style
  • The sum of products type representation
  • Translating between the type and representation
  • Writing a datatype-generic function
  • Adding a new datatype
  • GHC.Generics - a generic deriving mechanism
  • Origami programming
  • Tying the recursive knot
  • The generic map
  • The generic fold
  • main = print $ gfold addL aListF
  • Generic unfold and fold
  • Origami design patterns
  • Scrap your boilerplate
  • The type-safe cast with typeable
  • Type-safe function application
  • The shallow traversal and the data type-class
  • Typeable and data
  • Scrap your boilerplate
  • Summary
  • Chapter 7: Patterns of Kind Abstraction
  • Higher-order kinds
  • Higher-kinded polymorphism
  • Associated type synonyms
  • Using functional dependencies
  • Associated type synonyms
  • Associated types versus functional dependencies
  • Type (synonym) families
  • Data families
  • Kind polymorphism
  • The PolyKinds language extension
  • Type promotion
  • Promoting types to kinds
  • Type-level programming
  • Promoting term-level programs to type-level
  • Closed type families
  • The history of type-level programming in Haskell
  • Type-level and generic programming
  • Dependently-typed programming
  • Haskell and dependently-typed programming
  • Summary
  • Epilogue
  • Index

Dateiformat: ePUB
Kopierschutz: Adobe-DRM (Digital Rights Management)

Systemvoraussetzungen:

Computer (Windows; MacOS X; Linux): Installieren Sie bereits vor dem Download die kostenlose Software Adobe Digital Editions (siehe E-Book Hilfe).

Tablet/Smartphone (Android; iOS): Installieren Sie bereits vor dem Download die kostenlose App Adobe Digital Editions oder die App PocketBook (siehe E-Book Hilfe).

E-Book-Reader: Bookeen, Kobo, Pocketbook, Sony, Tolino u.v.a.m. (nicht Kindle)

Das Dateiformat ePUB ist sehr gut für Romane und Sachbücher geeignet - also für "fließenden" Text ohne komplexes Layout. Bei E-Readern oder Smartphones passt sich der Zeilen- und Seitenumbruch automatisch den kleinen Displays an. Mit Adobe-DRM wird hier ein "harter" Kopierschutz verwendet. Wenn die notwendigen Voraussetzungen nicht vorliegen, können Sie das E-Book leider nicht öffnen. Daher müssen Sie bereits vor dem Download Ihre Lese-Hardware vorbereiten.

Bitte beachten Sie bei der Verwendung der Lese-Software Adobe Digital Editions: wir empfehlen Ihnen unbedingt nach Installation der Lese-Software diese mit Ihrer persönlichen Adobe-ID zu autorisieren!

Weitere Informationen finden Sie in unserer E-Book Hilfe.


Dateiformat: PDF
Kopierschutz: Adobe-DRM (Digital Rights Management)

Systemvoraussetzungen:

Computer (Windows; MacOS X; Linux): Installieren Sie bereits vor dem Download die kostenlose Software Adobe Digital Editions (siehe E-Book Hilfe).

Tablet/Smartphone (Android; iOS): Installieren Sie bereits vor dem Download die kostenlose App Adobe Digital Editions oder die App PocketBook (siehe E-Book Hilfe).

E-Book-Reader: Bookeen, Kobo, Pocketbook, Sony, Tolino u.v.a.m. (nicht Kindle)

Das Dateiformat PDF zeigt auf jeder Hardware eine Buchseite stets identisch an. Daher ist eine PDF auch für ein komplexes Layout geeignet, wie es bei Lehr- und Fachbüchern verwendet wird (Bilder, Tabellen, Spalten, Fußnoten). Bei kleinen Displays von E-Readern oder Smartphones sind PDF leider eher nervig, weil zu viel Scrollen notwendig ist. Mit Adobe-DRM wird hier ein "harter" Kopierschutz verwendet. Wenn die notwendigen Voraussetzungen nicht vorliegen, können Sie das E-Book leider nicht öffnen. Daher müssen Sie bereits vor dem Download Ihre Lese-Hardware vorbereiten.

Bitte beachten Sie bei der Verwendung der Lese-Software Adobe Digital Editions: wir empfehlen Ihnen unbedingt nach Installation der Lese-Software diese mit Ihrer persönlichen Adobe-ID zu autorisieren!

Weitere Informationen finden Sie in unserer E-Book Hilfe.


Als Download verfügbar

28,05 €
inkl. 7% MwSt.
E-Book Einzellizenz
ePUB mit Adobe-DRM
siehe Systemvoraussetzungen
PDF mit Adobe-DRM
siehe Systemvoraussetzungen
Hinweis: Die Auswahl des von Ihnen gewünschten Dateiformats und des Kopierschutzes erfolgt erst im System des E-Book Anbieters
E-Book bestellen