Production Haskell
Minimum price
Suggested price

Production Haskell

Succeeding in Industry with Haskell

About the Book

So you've learned Haskell. You've taught your friends about monads, you've worked through some beginner textbooks, and maybe you've played around with some open source projects. Now that you've had a taste, you want more: you want to write an application in Haskell for fun! Maybe you want to use Haskell at work!

You sit down at your computer, and you're stuck.

How does anyone actually get anything done with this language?

This is a common thing to wonder.

Haskell has always enjoyed a wide variety of high quality learning material for advanced parts of the language, if you're not afraid of academic papers. The last five years have seen an upswelling of fantastic resources for learning the language as a beginner. However, the language does not have many resources for using it in production. It's difficult to navigate the ecosystems and identify quality resources that are in alignment with your goals and values.

This book aims to help with that situation. After reading this book, you should feel comfortable writing large software projects in Haskell, evaluating competing libraries and techniques, and productively reading material from a variety of Haskell users.

An Opinionated Tour Guide

Haskell is a hugely diverse landscape.

There are many regional groups: United Kingdom, Scandinavia, mainland Europe, Russia, the USA, Japan, China, and India all have thriving Haskell ecosystems that have interesting dialects and differences in custom and practice.

People come to Haskell with many backgrounds. Some people learned Haskell well into their careers, and had a long career writing Java, Scala, or C# beforehand. Some people came to Haskell from dynamically typed languages, like LISP or Ruby. Some people started learning Haskell very early on in their programming career, and use it as the basis of comparison. Some people primarily use Haskell in academic research, while others primarily use Haskell in industrial applications. Some people are hobbyists and just like to write Haskell for fun!

This book is intended for people that want to write Haskell in industry. The tradeoffs and constraints that industrial programmers face are different from academic or hobbyist programmers. This book will cover not only technical aspects of the Haskell language, but also social and engineering concerns that aren't "really" about Haskell.

Part of this book will be objective. I will teach you how to use some interesting techniques and ideas to make developing with Haskell more productive. We'll learn about Template Haskell, type-level programming, and other fun topics.

However, for the most part, this book is inherently subjective. Because Haskell serves so many ecosystems, it is imperative to discern what ecosystem a something is intended for. More than just giving out prescriptions - "This library is production ready! This is a toy!" - I hope to show my thought process and allow you to make your own judgment calls.

Ultimately, this is a book about the social reality of software engineering in niche languages.

About the Author

I'm Matt Parsons. I started learning programming in January 2014 with Java because I wanted to change careers. I learned JavaScript that summer with the excellent book [Eloquent JavaScript][eloquent-javascript]. It had a chapter on functional programming and object oriented programming. I found the chapter on functional programming more intuitive, so I made a mental note to learn the most functional language I could find. A few months later, I started learning Haskell.

My brain picked up Haskell extremely quickly. I had barely started learning imperative and object-oriented programming, so the difficult novelty of learning new jargon and concepts was expected. In August 2015, I started a Haskell internship, and I was able to use Haskell in my Artificial Intelligence coursework. In my last semester of college, I was able to use Haskell in my undergraduate thesis to study the connection between category theory, modal logic, and distributed systems.

I was extremely fortunate to have these opportunities, as they set me up for success to work with Haskell. My first job out of college was converting PHP applications to greenfield Haskell, and I've been working full-time with Haskell ever since. I've worked in a variety of contexts: a startup that wasn't 100% sold on Haskell, a larger company that was sold on Haskell but wrestling with social and technical difficulties of a huge code base and development team, and a startup that was sold on Haskell and working on growing. I also contribute to many open source projects, and I'm familiar with most of the ecosystems. All told, I have worked with nearly a million lines of Haskell code!

I've seen Haskell fail, and I've seen it succeed. I'd like to help you succeed with Haskell.

  • Share this book

  • Feedback

    You must own a copy of this Book to access the forums.

    Email the Author(s)

About the Author

Matt Parsons
Matt Parsons

Hi! I’m Matt Parsons! I like to ride my bicycle, play guitar, learn cello, and occasionally program a computer. I work as a software engineer for Lumi.

I started learning a software in Spring 2014 in my “intro to Java” course at UGA. JavaScript introduced me to functional programming that summer, and Ruby on Rails pointed me towards Sandi Metz and Smalltalk-inspired object oriented design. Haskell caught my interest and I started learning it in earnest in early 2015. Ever since, I’ve been sold on functional programming.

I tend to like abstraction, patterns, extremes in contrast, and going a little too meta. There’s an underpinning to writing music, learning mathematics, and making beautiful programs that resonate with me. Emergent complexity, chaotic systems, and expressions of passion are my favorite things.

Table of Contents

      • v6-2021-02-01
      • v5-2021-01-01
      • v4-2020-12-01
      • v3-2020-11-01
      • v2-2020-10-14
      • v1-2020-10-07
    • Introduction
      • An Opinionated Tour Guide
      • About the Author
    • Acknowledgements
    • Principles
      • Complexity
      • Novelty
      • Cohesion
      • Empathy
      • References
  • I Building Haskell Teams
    • 1. Selling Haskell
      • 1.1 Assessing Receptiveness
      • 1.2 Software Productivity
      • 1.3 Statistics of Productivity
      • 1.4 Know Your Competition
    • 2. Learning and Teaching Haskell
      • 2.1 The Philology of Haskell
      • 2.2 Programming Isn’t Easy To Learn
      • 2.3 Pick Learning Materials
      • 2.4 Write Lots of Code
      • 2.5 Don’t Fear the GHC
      • 2.6 Start Simple
      • 2.7 Solve Real Problems
      • 2.8 Pair Programming
      • 2.9 A Dialogue
      • 2.10 References
    • 3. Hiring Haskellers
      • 3.1 The Double Edged Sword
      • 3.2 Juniors and Seniors
      • 3.3 Hiring Seniors
      • 3.4 Hiring Juniors
    • 4. Evaluating Consultancies
      • 4.1 Identifying the Target
      • 4.2 Well-Typed
      • 4.3 FP Complete
  • II Application Structure
    • 5. The Beginning
      • 5.1 Abstraction for Mocking
      • 5.2 Forward Compatibility
      • 5.3 AppEnvironment
      • 5.4 The ReaderT Pattern
      • 5.5 Embed, don’t Stack
    • 6. Three Layer Haskell Cake
      • 6.1 Layer 1: Imperative Programming
      • 6.2 Layer 2: Object Oriented Programming
      • 6.3 Layer 3: Functional Programming
      • 6.4 Examples
    • 7. Invert Your Mocks!
      • 7.1 Decomposing Effects
      • 7.2 Streaming Decomposition
      • 7.3 Plain ol’ abstraction
      • 7.4 Decompose!!!
      • 7.5 What if I need to?
    • 8. Project Preludes
      • 8.1 Prelude Problems
      • 8.2 Custom Benefits
      • 8.3 Off-The-Shelf Preludes
      • 8.4 Nesting Preludes
      • 8.5 Downsides
      • 8.6 Using a Custom Prelude
    • 9. Optimizing GHC Compile Times
      • 9.1 The Project.Types Megamodule
      • 9.2 Package Splitting
      • 9.3 Big Ol Instances Module
      • 9.4 Some random parting thoughts
      • 9.5 Results
  • III Domain Modeling
    • 10. Type Safety Back and Forth
      • 10.1 The Ripple Effect
      • 10.2 Ask Only What You Need
    • 11. Keep Your Types Small…
      • 11.1 Expansion and Restriction
      • 11.2 Constraints Liberate
      • 11.3 Restrict the Range
      • 11.4 A perfect fit
    • 12. The Trouble with Typed Errors
      • 12.1 Monolithic error types are bad
      • 12.2 Boilerplate be gone!
      • 12.3 Type Classes To The Rescue!
    • 13. Exceptions
      • 13.1 Exceptions In Five Minutes
      • 13.2 Best Practices
      • 13.3 Hierarchies
      • 13.4 Reinventing
      • 13.5 Asynchronous Exceptions
      • 13.6 The Theory
      • 13.7 HasCallStack
    • 14. EDSL Design
      • 14.1 Tricks with do
      • 14.2 Overloaded Literals
      • 14.3 Type Inference Trick
      • 14.4 Fluent Interfaces
      • 14.5 Case Study: Weightlifting Logging
      • 14.6 Case Study: rowdy
      • 14.7 Case Study: hspec
    • 15. Growing Pains
      • 15.1 A Taxonomy of Breaking Changes
      • 15.2 Avoiding Breaking Changes
      • 15.3 Communicating To Users
  • IV Interfacing the Real
    • 16. Testing
      • 16.1 Libraries and Tools
      • 16.2 Designing Code for Testing
    • 17. Mocking
      • 17.1 Case Study: MonadLock
    • 18. Logging
      • 18.1 Logging Contexts
      • 18.2 Library Comparison
    • 19. Databases
      • 19.1 Separate Database Types
      • 19.2 Schema Migrations
      • 19.3 Data Migrations
      • 19.4 Access Patterns
      • 19.5 Conclusion
    • 20. Database Library Comparisons
    • 21. Profiling
  • V Advanced Haskell
    • 22. Template Haskell Is Not Scary
      • 22.1 A Beginner Tutorial
      • 22.2 wait this isn’t haskell what am i doing here
      • 22.3 Constructing an AST
      • 22.4 Boilerplate Be Gone!
    • 23. Basic Type Level Programming
      • 23.1 The Basic Types
      • 23.2 The Higher Kinds
      • 23.3 Dynamically Kinded Programming
      • 23.4 Data Kinds
      • 23.5 GADTs
      • 23.6 Vectors
      • 23.7 Type Families
      • 23.8 This Sucks
      • 23.9 Heterogeneous Lists
      • 23.10 Inductive Type Class Instances
      • 23.11 Extensible Records
      • 23.12 Like what you read?
    • 24. Trade-offs in Type Programming
      • 24.1 MPTCs
      • 24.2 MPTCs + Fundeps
      • 24.3 Associated Types
      • 24.4 Comparisons
    • 25. Case Study: Prairie
      • 25.1 Problem Statement:
      • 25.2 Prior Art
      • 25.3 The GADT Approach
      • 25.4 Improvements?
      • 25.5 Symbols
      • 25.6 Compare and Constrast
      • 25.7 Identify the Issue
      • 25.8 Generalize a GADT
      • 25.9 Fundeps
      • 25.10 More Class Please
      • 25.11 Refining the Class
      • 25.12 Template Haskell
      • 25.13 Conclusion
  • Notes

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms

Do Well. Do Good.

Authors have earned$10,479,622writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF, EPUB and/or MOBI files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub