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

  • Categories

    • Haskell
  • 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'm the team lead for the Backend Developer Experience at Mercury.

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

    • 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 Is Hard 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 TemplateHaskell
      • 9.5 Some random parting thoughts
  • 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!
      • 12.4 The virtue of untyped errors
    • 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. Logging and Observability
      • 17.1 On Debug.Trace
      • 17.2 Prefer do Notation
      • 17.3 Logging Contexts
      • 17.4 Libraries in Brief
    • 18. Databases
      • 18.1 Separate Database Types
      • 18.2 Migrations
      • 18.3 Access Patterns
      • 18.4 Conclusion
  • V Advanced Haskell
    • 19. Template Haskell Is Not Scary
      • 19.1 A Beginner Tutorial
      • 19.2 wait this isn’t haskell what am i doing here
      • 19.3 Constructing an AST
      • 19.4 Boilerplate Be Gone!
    • 20. Basic Type Level Programming
      • 20.1 The Basic Types
      • 20.2 The Higher Kinds
      • 20.3 Dynamically Kinded Programming
      • 20.4 Data Kinds
      • 20.5 GADTs
      • 20.6 Vectors
      • 20.7 Type Families
      • 20.8 This Sucks
      • 20.9 Heterogeneous Lists
      • 20.10 Inductive Type Class Instances
      • 20.11 Extensible Records
      • 20.12 Like what you read?
    • 21. Family Values
      • 21.1 Type Families
      • 21.2 Open or Closed Type Families?
      • 21.3 The Bridge Between Worlds
      • 21.4 Data Families
      • 21.5 Conclusion
    • 22. Trade-offs in Type Programming
      • 22.1 MPTCs
      • 22.2 MPTCs + Fundeps
      • 22.3 Associated Types
      • 22.4 Comparisons
    • 23. Case Study: Prairie
      • 23.1 Problem Statement:
      • 23.2 Prior Art
      • 23.3 The GADT Approach
      • 23.4 Improvements?
      • 23.5 Symbols
      • 23.6 Compare and Constrast
      • 23.7 Identify the Issue
      • 23.8 Generalize a GADT
      • 23.9 Fundeps
      • 23.10 More Class Please
      • 23.11 Refining the Class
      • 23.12 Template Haskell
      • 23.13 Conclusion
  • Notes

The Leanpub 60 Day 100% Happiness Guarantee

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

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $12 millionwriting, publishing and selling on Leanpub.

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) and EPUB (for phones, tablets and 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 and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub