Leanpub Header

Skip to main content

Production Haskell

Succeeding in Industry with Haskell

Are you excited about Haskell, but don't know where to begin? Are you thrilled by the technical advantages, but worried about the unknown pitfalls? This book has you covered.

The author is letting you choose the price you pay for this book!

Pick Your Price...
PDF
EPUB
WEB
About

About

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

Price

Pick Your Price...

Minimum price

$30.00

$40.00

You pay

$40.00

Author earns

$32.00
$

All prices are in US $. You can pay in US $ or in your local currency when you check out.

EU customers: prices exclude VAT, which is added during checkout.

...Or Buy With Credits!

Number of credits (Minimum 2)

2
The author will earn $24.00 from your purchase!
You can get credits monthly with a Reader Membership

Author

About the Author

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.

Leanpub Podcast

Episode 195

An Interview with Matt Parsons

Translations

Translations

Languages

Contents

Table of Contents

Introduction

  1. An Opinionated Tour Guide
  2. About the Author

Acknowledgements

Principles

  1. Complexity
  2. Novelty
  3. Cohesion
  4. Empathy
  5. References
  6. IBuilding Haskell Teams

1.Selling Haskell

  1. 1.1Assessing Receptiveness
  2. 1.2Software Productivity
  3. 1.3Statistics of Productivity
  4. 1.4Know Your Competition

2.Learning and Teaching Haskell

  1. 2.1The Philology of Haskell
  2. 2.2Programming Is Hard To Learn
  3. 2.3Pick Learning Materials
  4. 2.4Write Lots of Code
  5. 2.5Don’t Fear the GHC
  6. 2.6Start Simple
  7. 2.7Solve Real Problems
  8. 2.8Pair Programming
  9. 2.9A Dialogue
  10. 2.10References

3.Hiring Haskellers

  1. 3.1The Double-edged Sword
  2. 3.2Juniors and Seniors
  3. 3.3Hiring Seniors
  4. 3.4Hiring Juniors

4.Evaluating Consultancies

  1. 4.1Identifying the Target
  2. 4.2Well-Typed
  3. 4.3FP Complete
  4. IIApplication Structure

5.The Beginning

  1. 5.1Abstraction for Mocking
  2. 5.2Forward Compatibility
  3. 5.3AppEnvironment
  4. 5.4The ReaderT Pattern
  5. 5.5Embed, don’t Stack

6.Three Layer Haskell Cake

  1. 6.1Layer 1: Imperative Programming
  2. 6.2Layer 2: Object Oriented Programming
  3. 6.3Layer 3: Functional Programming
  4. 6.4Examples

7.Invert Your Mocks!

  1. 7.1Decomposing Effects
  2. 7.2Streaming Decomposition
  3. 7.3Plain ol’ abstraction
  4. 7.4Decompose!!!
  5. 7.5What if I need to?

8.Project Preludes

  1. 8.1Prelude Problems
  2. 8.2Custom Benefits
  3. 8.3Off-The-Shelf Preludes
  4. 8.4Nesting Preludes
  5. 8.5Downsides
  6. 8.6Using a Custom Prelude

9.Optimizing GHC Compile Times

  1. 9.1The Project.Types Megamodule
  2. 9.2Package Splitting
  3. 9.3Big Ol’ Instances Module
  4. 9.4TemplateHaskell
  5. 9.5Some random parting thoughts
  6. IIIDomain Modeling

10.Type Safety Back and Forth

  1. 10.1The Ripple Effect
  2. 10.2Ask Only What You Need

11.Keep Your Types Small…

  1. 11.1Expansion and Restriction
  2. 11.2Constraints Liberate
  3. 11.3Restrict the Range
  4. 11.4A perfect fit

12.The Trouble with Typed Errors

  1. 12.1Monolithic error types are bad
  2. 12.2Boilerplate be gone!
  3. 12.3Type Classes To The Rescue!
  4. 12.4The virtue of untyped errors

13.Exceptions

  1. 13.1Exceptions In Five Minutes
  2. 13.2Best Practices
  3. 13.3Hierarchies
  4. 13.4Reinventing
  5. 13.5Asynchronous Exceptions
  6. 13.6The Theory
  7. 13.7HasCallStack

14.EDSL Design

  1. 14.1Tricks with do
  2. 14.2Overloaded Literals
  3. 14.3Type Inference Trick
  4. 14.4Fluent Interfaces
  5. 14.5Case Study: Weightlifting Logging
  6. 14.6Case Study: rowdy
  7. 14.7Case Study: hspec

15.Growing Pains

  1. 15.1A Taxonomy of Breaking Changes
  2. 15.2Avoiding Breaking Changes
  3. 15.3Communicating To Users
  4. IVInterfacing the Real

16.Testing

  1. 16.1Libraries and Tools
  2. 16.2Designing Code for Testing

17.Logging and Observability

  1. 17.1On Debug.Trace
  2. 17.2Prefer do Notation
  3. 17.3Logging Contexts
  4. 17.4Libraries in Brief

18.Databases

  1. 18.1Separate Database Types
  2. 18.2Migrations
  3. 18.3Access Patterns
  4. 18.4Conclusion
  5. VAdvanced Haskell

19.Template Haskell Is Not Scary

  1. 19.1A Beginner Tutorial
  2. 19.2wait this isn’t haskell what am i doing here
  3. 19.3Constructing an AST
  4. 19.4Boilerplate Be Gone!

20.Basic Type Level Programming

  1. 20.1The Basic Types
  2. 20.2The Higher Kinds
  3. 20.3Dynamically Kinded Programming
  4. 20.4Data Kinds
  5. 20.5GADTs
  6. 20.6Vectors
  7. 20.7Type Families
  8. 20.8This Sucks
  9. 20.9Heterogeneous Lists
  10. 20.10Inductive Type Class Instances
  11. Further Exercises
  12. 20.11Extensible Records
  13. Exercise:
  14. 20.12Like what you read?

21.Family Values

  1. 21.1Type Families
  2. 21.2Open or Closed Type Families?
  3. 21.3The Bridge Between Worlds
  4. 21.4Data Families
  5. 21.5Conclusion

22.Trade-offs in Type Programming

  1. 22.1MPTCs
  2. 22.2MPTCs + Fundeps
  3. 22.3Associated Types
  4. 22.4Comparisons

23.Case Study: Prairie

  1. 23.1Problem Statement:
  2. 23.2Prior Art
  3. 23.3The GADT Approach
  4. 23.4Improvements?
  5. 23.5Symbols
  6. 23.6Compare and Constrast
  7. 23.7Identify the Issue
  8. 23.8Generalize a GADT
  9. 23.9Fundeps
  10. 23.10More Class Please
  11. 23.11Refining the Class
  12. 23.12Template Haskell
  13. 23.13Conclusion

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

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

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

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

In fact, authors have earned over $14 million writing, 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