Leanpub Header

Skip to main content

Topics

Haskell

From values, types and purity to type classes, monads, optics, type-level programming, property-based testing and running Haskell in production, Haskell as told through the free samples of the Leanpub books about it.

Created from the free samples of 14 Leanpub books and the descriptions and tables of contents of 4 more, with every source cited.

Haskell is a purely functional programming language with static types and lazy evaluation. A program is built from functions that compute values and do nothing else, effects such as input and output are marked in the types of the functions that perform them, and a compiler that infers and checks those types rejects a large class of mistakes before the program runs. A recent guide on this shelf acknowledges the language's reputation as academic, exotic and impractical, and answers that it is a production language resting on long research into type theory and language design, used in finance and technology companies.[15]

The books divide between those two views of it. Some follow the types as far as they will go: one sets out to teach readers to look for chances to make less code compile, on the principle that a little frustration with the type-checker is better than a fault found in production, and in the same breath warns that the technique is best in moderation.[1] Others are written from the workplace, and the most outspoken of them holds that managing complexity is the most important and most difficult task in a Haskell project, and says so twice.[2] Between them is a group of patient introductions, each built on one small problem.

This article covers where to begin, the history, the language, monads and other abstractions, optics, programming with types, design, testing, and building real applications. Its sources are the free samples of the Leanpub books listed at the end, with the descriptions and tables of contents of the books whose samples were not available, and every claim that rests on a source is cited to it.

Where to start

Three books are written for newcomers. Happy Learn Haskell Tutorial Volume 1 (2022) assumes no programming experience at all and teaches through many small programs that the reader reads, types in and then alters;[6] Finding Success (and Failure) in Haskell (2020) assumes very little Haskell and grows a single program for validating a username and password, giving, as it says, just enough information at the time it is needed;[5] and Texas Hold'em (2019) proceeds as a dialogue of questions and answers round one problem, the ranking of hands of cards.[13] The Haskell Blueprint is a direct guide for developers who program in other languages.[15]

Readers past the basics have projects and libraries. Sockets and Pipes (2023) is for learners who can write a case expression and sequence a few actions and are ready for something substantial;[8] The Simple Haskell Handbook (2021) builds a complete application for readers who know the basics of the language;[9] Haskell (almost) Standard Libraries (2022) maps the libraries that every practitioner ends up needing;[14] and Optics By Example (2020) takes one family of tools from the beginning to advanced use.[3] Book of Monads (2021) asks for basic functional programming with static types and names the beginner's books it expects to have been read.[7]

The advanced books are Thinking with Types (2019), the most widely sold of the core books here, for programmers who can already solve real problems in the language,[1] Pragmatic Type-Level Design (2025) on the same subject as a discipline of design,[10] Algebra-Driven Design (2023) on a method of designing software,[4] and Production Haskell (2023), for people who have learned the language and want to build and maintain large applications in it at work.[2]

History

Haskell was defined in 1990 by a committee of researchers who wanted a common, open language in place of the dozen lazy functional languages then in use, and it was revised into a stable standard in 1998 and again in 2010. For its first fifteen years it was mainly a vehicle for research, and several ideas now found in mainstream languages, type classes, monads for structuring effects, and testing by randomly generated cases, were worked out in it. From the mid-2000s a package repository and build tools made commercial use practical, and one compiler, continually extended, became in effect the definition of the language.

The books touch this history at several points. The foreword to Algebra-Driven Design observes that computer scientists have been interested in the algebra of programs for more than half a century and quotes a paper of 1966 on equivalences between pieces of program that nearly hold and do not quite.[4] The (Little) QuickCheck Workbook (2015) notes that the library for property-based testing has existed since 2000.[16] Production Haskell is the testimony of the commercial period: its author came to the language in 2014, has worked at companies of several sizes that used it, and writes of having worked with millions of lines of it, and of having seen it fail as well as succeed.[2] Two books on the shelf mark themselves as superseded: Functional Design and Architecture (Early Edition, 2020) (2020) is an early, self-published edition of a book since issued by a publisher,[11] and the adjacent Plutus: Writing reliable smart contracts (2019), on a language for financial contracts that is based on Haskell, carries a notice that it describes that language as it then was.[18]

The language

Happy Learn Haskell Tutorial Volume 1 is the gentlest way in. Its authors describe their own experience of learning to program, books that filled the head with knowledge and gave no guidance in the craft, programs cluttered with detail, and tedious practice before the fog lifted, and set out to spare the reader that. The first chapters cover values, types, definitions and functions and a first program; a chapter called the main road explains how a program is made and what purity means, with the claim that everything in the language is pure; and one on functions introduces, through a story about coins, functions that return functions. The method is stated at the outset. The eager beginner, the authors write, tackles too much too soon and ends in a muddle, so learning here goes in two stages: each lesson presents several programs to be read, understood and typed in, and then changes them slightly to show what difference the change makes.[6]

Finding Success (and Failure) in Haskell began as a course at a local meeting of users who had heard about monads and type classes and did not yet find them concrete. Its method is to take one problem, checking what a user has typed into a form, write a few plain functions and then refactor them through one type after another, some of them monads and some not, until the reader understands by use why each is what it is. The motivating difficulty is reporting every error in a form and not only the first. Most languages, the book notes, have some way of combining small programs that might fail into a larger one that might fail. In the imperative style instructions run in sequence and stop at the first error, so the program can report only the first problem it met. The authors hold that functional programming with type classes is the one setting they know in which the ideal program, which lists every problem, is no harder to write than the flawed one, and they offer this as the answer to the question of why monads matter: the class generalises the idea of a program beyond running a series of steps until one fails.[5] Texas Hold'em reaches the same ground, type classes, partial application and the composition of functions, in the course of teaching a program to recognise a flush or two pairs.[13]

Type classes are explained compactly in Book of Monads: a class declares operations, such as equality, that a type may support; an instance supplies them for a particular type; and an instance may depend on others, so that lists can be compared whenever their elements can. The book remarks that both words mean something different here from what they mean in object-oriented languages.[7]

Monads and other abstractions

Book of Monads calls its subject one of the core concepts of modern functional programming and one of the most misunderstood. It is organised in five parts, the first on what all monads share, including the special notation that functional languages provide for them and the functions that work on every one, the later ones on particular monads, on combining them and on the theory, and it chooses its topics, the author says, by what works and is used, with occasional detours. Its code is given in two languages side by side.[7] Sockets and Pipes introduces the same abstractions as a server needs them, among them a transformer for errors, another for shared context, and transactional memory for state that several threads change.[8]

Optics

Data in Haskell is immutable, so changing a field deep inside a structure means building a new structure, and optics are the library answer to the labour of doing so. Optics By Example defines them as a family of tools that work together, lenses, folds, traversals, prisms and isomorphisms among them, with new kinds still being found, and more exactly as composable combinators for building transformations of data that run in both directions. Their strengths, as the book lists them, begin with composition: each optic focuses on some part of the data, and another can continue from where it stopped, so that every optic learned is a new word in a vocabulary from which sentences can be made. The second is a separation of concerns stronger, it claims, than either object-oriented or functional programming gives by itself.[3] Finding Success (and Failure) in Haskell ends at the same library, having met in its own example the wish for a more general way of reaching into a structure.[5]

Programming with types

Thinking with Types is a guide to computation in the type system. The reader it wants has a healthy unease: comments warning that a function must not be called with a certain value, and calls to an error that supposedly cannot happen, ought to prompt the question whether the compiler could be taught the rule. Yet the book takes seriously the complaint of programmers in dynamically typed languages that types get in the way, concedes that they often do, and gives as its instance a formatting function in an older language whose arguments depend on the contents of a string, something that language's types cannot describe. Its advice on when to use the techniques is a matter of style: when in doubt, do not; save them for cases where an error would be catastrophic, where a little goes a long way, or where an interface is much improved. A financial system that moves billions deserves them, and a hobbyist's game that draws one frame wrongly does not. The first part of the book is on fundamentals and opens with the algebra behind types, counting the values a type can have and showing when two types are interchangeable.[1]

Pragmatic Type-Level Design comes at the subject from frustration with how it is taught. Its author found the available material either academic, centred on the mathematical foundations, or scattered, more like folklore than structured knowledge, and wanted a practical framework for designing software with types, from principles to implementation; one part translates the ideas into two other languages.[10]

Design

Algebra-Driven Design proposes designing software by first describing a domain as an algebra, a set of operations and the laws that relate them, and then deriving tests and efficient implementations from the laws. Its foreword makes the case with school algebra. Writing a sum of four terms without brackets relies on the associative law, and so does every loop that adds up an array; the law fails for floating-point numbers, so the ordinary loop gives a wrong answer for a million of them; and the lesson drawn is that when algebraic laws fail the ground moves under the programmer's feet. The book's contents go on to the properties that recur, associativity, identity, idempotency, distributivity, and to tools that discover laws automatically.[4]

Functional Design and Architecture (Early Edition, 2020) treats the design of whole applications in functional languages, with two showcase projects, one of them a simulator of the control software of a simple spacecraft, followed from the gathering of requirements to a working program, and a first chapter on complexity, which its author describes as the main problem that developers face: a large system tends to grow larger and more complex, and resists attempts to change it.[11] Production Haskell makes complexity a matter of budget. A project has a budget for complexity and another for novelty, spent by adopting sophisticated or unfamiliar techniques, and unlike technical debt these have a direct effect on the real budget. Complexity is not adopted for its own sake; small features and safety devices accumulate, each seeming to pay its way, but because every unit of code must be understood by the code that uses it, complexities multiply while their benefits only add. Safety features in particular forbid invalid programs, and become a hindrance when requirements change what counts as invalid. A system that has become too hard to understand is in the end rewritten from the ground up, which the author says often kills the project if not the company, and before that point every estimate of the time a change will take grows less reliable. The other principles the book names are novelty, cohesion and empathy.[2]

Testing

Property-based testing, in which a library generates many inputs and checks that a stated property holds for all of them, originated in Haskell. The (Little) QuickCheck Workbook is a workbook of exercises in it, on examples such as sorting a menu, modelling money and a vending machine.[16] Property-Based Testing in a Screencast Editor (2019) was written because introductions to the technique stop at ideal pure functions such as reversing a list, and its author, wanting to test a video editor with a graphical interface, found them no help. The book is a set of case studies on increasingly complex parts of that application, each with the author's reflections, the faults the tests found and what remains to be improved, and it asks of its reader only a basic understanding of functional programming. It describes itself as a collection of motivating examples and not a tutorial, written to persuade readers that the technique is useful in the code of daily work.[12] Algebra-Driven Design derives its tests from the laws of a design.[4]

Building real applications

The Simple Haskell Handbook builds a continuous integration server from nothing, and its first pages show how design begins in the language: with types. A build runs commands in a sandbox and reports the result; a pipeline is made of steps; each step names its commands and the image in which to run them. Those sentences become data declarations almost word for word, with distinct types wrapped round plain text so that a step's name cannot be confused with an image's, and the states through which a build passes become a type whose values are ready, running and finished.[9]

Sockets and Pipes began with the question of what exactly a web server is. Answering it without assuming much background, the preface says, spans several areas of computing, each of which serves as a reason to learn more of the language. The book implements the protocol of the web from its published definition, starting by taking apart a program that prints a greeting to see the bytes underneath, on the view that a full understanding of the lower layers lets a developer use a platform better and judge when another protocol would serve. It lists exactly what it assumes, down to the handful of types and classes from the base library with which the reader should be familiar, and assumes no other library or language extension.[8] Haskell (almost) Standard Libraries addresses the other threshold between beginner and practitioner. The language's base library is small, and for most tasks there is one library that the community has settled on; the book goes through them by topic, from containers and text to parsing, streaming, concurrency, web servers and testing.[14] Retrocomputing with Clash (2022) takes the language furthest from its usual ground, describing digital circuits in it and building old computers and games as hardware.[17]

Questions about Haskell

Which Haskell book should I start with?

A reader with no programming experience at all can begin with Happy Learn Haskell Tutorial Volume 1 (2022), which teaches through many small programs that the reader reads, types in and then alters.[6] Finding Success (and Failure) in Haskell (2020) assumes very little Haskell and grows a single program for validating a username and password, and The Haskell Blueprint is a direct guide for developers who program in other languages.[5][15] Learners past the basics who are ready for something substantial have Sockets and Pipes (2023).[8]

Is Haskell used in production?

The Haskell Blueprint acknowledges the language's reputation as academic, exotic and impractical, and answers that it is a production language used in finance and technology companies.[15] Production Haskell (2023) is written from the workplace: its author has worked at companies of several sizes that used the language, with millions of lines of it, and has seen it fail as well as succeed.[2] The book holds that managing complexity is the most important and most difficult task in a Haskell project.[2]

What is a type class in Haskell?

A type class declares operations, such as equality, that a type may support, and an instance supplies them for a particular type.[7] An instance may depend on others, so that lists can be compared whenever their elements can.[7] Book of Monads remarks that both words mean something different here from what they mean in object-oriented languages.[7]

Why do monads matter in Haskell?

Finding Success (and Failure) in Haskell answers through one problem, reporting every error in a form and not only the first.[5] In the imperative style instructions run in sequence and stop at the first error, so the program can report only the first problem it met.[5] The authors hold that functional programming with type classes is the one setting they know in which the program that lists every problem is no harder to write than the flawed one, because the class generalises the idea of a program beyond running a series of steps until one fails.[5]

What is property-based testing?

In property-based testing a library generates many inputs and checks that a stated property holds for all of them. The (Little) QuickCheck Workbook (2015) is a workbook of exercises in it, on examples such as sorting a menu, modelling money and a vending machine, and notes that the library has existed since 2000.[16] Property-Based Testing in a Screencast Editor (2019) applies the technique to a video editor with a graphical interface, because introductions to it stop at ideal pure functions such as reversing a list.[12]

When should I use type-level programming in Haskell?

The advice in Thinking with Types is a matter of style: when in doubt, do not, and save the techniques for cases where an error would be catastrophic, where a little goes a long way, or where an interface is much improved.[1] A financial system that moves billions deserves them, and a hobbyist's game that draws one frame wrongly does not.[1] Production Haskell adds that safety features forbid invalid programs and become a hindrance when requirements change what counts as invalid.[2]

Sources

Every source is a Leanpub book. The note after each says which part of it was read; where no sample was available, only the public description and table of contents were used.

  1. 1.
    Thinking with Types, Sandy Maguire: Type-Level Programming in Haskell Free sample: the introduction, on who the book is for and when types get in the way, and the opening of chapter one. 2019. Free sample: PDF
  2. 2.
    Production Haskell, Matt Parsons: Succeeding in Industry with Haskell Free sample: the introduction, the author's background and the principles, with the section on complexity. 2023. Free sample: PDF · EPUB
  3. 3.
    Optics By Example, Chris Penner: Functional lenses in Haskell Free sample: the opening of the chapter on what optics are and their strengths; the introduction is withheld. 2020. Free sample: PDF · EPUB
  4. 4.
    Algebra-Driven Design, Sandy Maguire: Elegant Solutions from Simple Building Blocks Free sample: the contents and the foreword. 2023. Free sample: PDF
  5. 5.
    Finding Success (and Failure) in Haskell, Type Classes: Fall in love with applicative functors Free sample: the contents, the preface and the opening of the first chapter. 2020. Free sample: PDF
  6. 6.
    Happy Learn Haskell Tutorial Volume 1, GetContented Free sample: the contents and the opening chapters, on how the authors learned and on values and types. 2022. Free sample: PDF
  7. 7.
    Book of Monads, Alejandro Serrano Mena Free sample: the contents, the introduction and a section on type classes. 2021. Free sample: PDF
  8. 8.
    Sockets and Pipes, Type Classes: Connect with Haskell Free sample: the contents and the preface, on scope and prerequisites. 2023. Free sample: PDF
  9. 9.
    The Simple Haskell Handbook, Marco Sampellegrini: Learn how to build Haskell applications. Free sample: the opening chapter, on modelling the domain. 2021. Free sample: PDF
  10. 10.
    Pragmatic Type-Level Design, Alexander Granin: Practical introduction to type-level programming: design principles, design patterns, methodologies, approaches Free sample: the author's foreword and the opening of chapter one. 2025. Free sample: PDF · EPUB
  11. 11.
    Functional Design and Architecture (Early Edition, 2020), Alexander Granin: Building real programs in static functional languages: application architectures, design patterns, best practices and approaches Free sample: the first chapter, on software design and complexity. 2020. Free sample: PDF · EPUB
  12. 12.
    Property-Based Testing in a Screencast Editor, Oskar Wickström: Case Studies from Komposition Free sample: the preface and the first case study. 2019. Free sample: PDF
  13. 13.
    Texas Hold'em, Christophe Thibaut: The Little Haskeller Free sample: the opening dialogue, on the problem and the first steps. 2019. Free sample: PDF
  14. 14.
    Haskell (almost) Standard Libraries, Alejandro Serrano Mena Free sample: the table of contents and the list of libraries by topic. 2022. Free sample: PDF
  15. 15.
    The Haskell Blueprint, Gautier DI FOLCO: A Direct Guide to Writing Maintainable, Real-World Software The free sample is a table of contents: from that and the description. 2026. Free sample: PDF
  16. 16.
    The (Little) QuickCheck Workbook, Willem van den Ende: Experience Property-Based Testing in Haskell No sample: from the description and table of contents of a book in progress. 2015.
  17. 17.
    Retrocomputing with Clash, Gergő Érdi: Haskell for FPGA Hardware Design No sample: from the description and table of contents. 2022.
  18. 18.
    Plutus: Writing reliable smart contracts, Lars Brünjes, Polina Vinogradova, Alejandro Garcia Fdz: NOTICE: This book is out of date. It shows PLUTUS as it was in 2019. We are currently working in the new edition that depicts the latest development of the PLUTUS programming language. No sample: from the description, which says the book is out of date. 2019.

Further reading

One more book in the library on neighbouring ground, not cited above.

This is an article created from the free samples of 14 Leanpub books and the descriptions and tables of contents of 4 more. We're building these articles to provide you, the Leanpub reader, with a good jumping-off point to discover more Leanpub books that are interesting and relevant to you. We never use material which is paid-only when building these articles: we only use material which is already free on Leanpub. However, Leanpub authors can opt out from inclusion in articles from their book settings page.

Updated November 2026.

In the Leanpub store: 24 books in the Haskell category

All topics