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

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 "m...

Full description

Bibliographic Details
Main Author: Lemmer, Ryan
Format: eBook
Language:English
Published: Birmingham, UK Packt Publishing 2015
Series:Community experience distilled
Subjects:
Online Access:
Collection: O'Reilly - Collection details see MPG.ReNa
Table of Contents:
  • Chapter 6: Patterns of Generic ProgrammingPatterns 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
  • Chapter 3: Patterns of CompositionFunctor; 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
  • 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 patternThe 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
  • The traversal and the Iterator patternModernizing 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