You are previewing Beginning Haskell A Project-Based Approach.
O'Reilly logo
Beginning Haskell A Project-Based Approach

Book Description

"

Beginning Haskell provides a broad-based introduction to the Haskell language, its libraries and environment, and to the functional programming paradigm that is fast growing in importance in the software industry. The book takes a project-based approach to learning the language that is unified around the building of a web-based storefront. Excellent coverage is given to the Haskell ecosystem and supporting tools. These include the Cabal build tool for managing projects and modules, the HUnit and QuickCheck tools for software testing, the Scotty framework for developing web applications, Persistent and Esqueleto for database access, and also parallel and distributed programming libraries.

Functional programming is gathering momentum, allowing programmers to express themselves in a more concise way, reducing boilerplate and increasing the safety of code. Indeed, mainstream languages such as C# and Java are adopting features from functional programming, and from languages implementing that paradigm. Haskell is an elegant and noise-free pure functional language with a long history, having a huge number of library contributors and an active community. This makes Haskell the best tool for both learning and applying functional programming, and Beginning Haskell the perfect book to show off the language and what it can do.

  • Takes you through a series of projects showing the different parts of the language.
  • Provides an overview of the most important libraries and tools in the Haskell ecosystem.
  • Teaches you how to apply functional patterns in real-world scenarios.

What you'll learn

  • Build small and large projects using the Haskell language.
  • Profit from ecosystem tools such as Cabal, HLint, and QuickCheck.
  • Implement efficient stream I/O via libraries like Conduit.
  • Parallelize code to run on multiple processors or distributed across a network.
  • Create domain-specific languages useable by business users, and to tackle specific problem domains.
  • Build Haskell-backed websites using database and web-application libraries such as Persistent, Esqueleto, and Scotty

Who this book is for

Beginning Haskell is for programmers new to functional programming, who want to learn this new paradigm and how it can improve the quality of their code. Beginning Haskell is also a great choice for functional programmers wanting to get a taste of the Haskell ecosystem and its unique features, or who wish to learn about advanced type system features and patterns.

"

Table of Contents

  1. Title Page
  2. Dedication
  3. Contents at a Glance
  4. Contents
  5. About the Author
  6. About the Technical Reviewer
  7. Acknowledgments
  8. Introduction
  9. PART 1: First Steps
    1. CHAPTER 1: Going Functional
      1. Why Haskell?
      2. The History of Haskell
      3. Your Working Environment
      4. First steps with GHCi
      5. The Time Machine Store
      6. Summary
    2. CHAPTER 2: Declaring the Data Model
      1. Working with Characters, Numbers, and Lists
      2. Creating a New Project
      3. Defining Simple Functions
      4. Working with Data Types
      5. Pattern Matching
      6. Records
      7. Summary
    3. CHAPTER 3: Reusing Code Through Lists
      1. Parametric Polymorphism
      2. Functions as Parameters
      3. More on Modules
      4. Diving into Lists
      5. List Comprehensions
      6. Haskell Origami
      7. Summary
    4. CHAPTER 4: Using Containers and Type Classes
      1. Using Packages
      2. Containers: Maps, Sets, Trees, Graphs
      3. Ad-hoc Polymorphism: Type Classes
      4. Binary Tress for the Minimum Price
      5. Container-related Type Classes
      6. Summary
    5. CHAPTER 5: Laziness and Infinite Structures
      1. An Infinite Number of Time Machines
      2. Lazy Evaluation Model
      3. Profiling with GHC
      4. Strictness Annotations
      5. Summary
  10. PART 2: Data Mining
    1. CHAPTER 6: Knowing Your Clients Using Monads
      1. Data Mining
      2. Discovering Monads
      3. Different Sorts of State
      4. Summary
    2. CHAPTER 7: More Monads: Now for Recommendations
      1. Returning More Than One Value
      2. Failures and Alternatives
      3. Association Rules Learning.
      4. Search Problems
      5. Monads and Lists Redux
      6. Combining Monads
      7. Summary
    3. CHAPTER 8: Working in Several Cores
      1. Parallelism, Concurrency, Distribution
      2. The Par Monad
      3. Software Transactional Memory
      4. Cloud Haskell
      5. Summary
  11. PART 3: Resource Handling
    1. CHAPTER 9: Dealing with Files: IO and Conduit
      1. Basic Input and Output
      2. Randomness
      3. Working with Files
      4. Error Handling
      5. Streaming Data with Conduit
      6. Looking Further than Text Files
      7. Summary
    2. CHAPTER 10: Building and Parsing Text
      1. The Five Textual Data Types
      2. Building as Fast as the Wind
      3. Parsing with attoparsec
      4. Introducing New Type Classes
      5. Don’t Overengineer: Just Use JSON
      6. Summary
    3. CHAPTER 11: Safe Database Access
      1. Database Access Landscape
      2. Connection
      3. Schemas and Migrations
      4. Queries
      5. Insertions, Updates, and Deletions
      6. Summary
    4. CHAPTER 12: Web Applications
      1. Haskell Web Ecosystem
      2. RESTful Structure
      3. Backend with Scotty
      4. Frontend with Fay
      5. Summary
  12. PART 4: Domain Specific Languages
    1. CHAPTER 13: Strong Types for Describing Offers
      1. Domain Specific Languages
      2. Adding Safety to the Expression Language
      3. Dependent Typing
      4. Type-level Programming in Haskell
      5. Functional Dependencies
      6. Type Families
      7. Data Type Promotion and Singletons
      8. Summary
    2. CHAPTER 14: Interpreting Offers with Attributes
      1. Interpretations and Attribute Grammars
      2. Your First Attribute Grammar
      3. Integrating UUAGC in Your Package
      4. Expressions Interpretation
      5. Offer Interpretations
      6. Origami Programming Over Any Data Type
      7. Summary
  13. PART 5: Engineering the Store
    1. CHAPTER 15: Documenting, Testing, and Verifying
      1. Documenting Binary Trees with Haddock
      2. Unit Testing with HUnit
      3. Randomized Testing with QuickCheck
      4. Formal Verification with Idris
      5. Summary
    2. CHAPTER 16: Architecting Your Application
      1. Design Patterns and Functional Programming
      2. Medium-Level Guidelines
      3. Tools
      4. Projects
      5. Summary
    3. APPENDIX A: Looking Further
      1. Haskell Resources
    4. APPENDIX B: Time Traveling with Haskell
  14. Index