Jump to ratings and reviews
Rate this book

Learn Haskell by Example

Rate this book
Learn Haskell by doing Haskell projects! In this book, you’ll get practical experience writing Haskell code and applying functional programming to actual development challenges.

In Learn Haskell by Example, you’ll build your Haskell skills by working through hands-on challenges and conundrums. You’ll learn to look at each project through a Haskell lens, and then solve it using features like lazy evaluation, immutable data structures, and monads.

In Learn Haskell by Example you will learn how Haskell for daily programming tasksEffectively apply functional conceptsAvoid common beginner pitfalls of HaskellApply abstract concepts in the Haskell languageDebug and profile Haskell applicationsImprove the performance of Haskell applications
Haskell is an amazing choice for applications that need an extra guarantee of safety, such as in smart contracts, data intensive applications, and large scale distributed systems. In this book, you’ll see just how practical Haskell can be for creating programs by building your own engaging projects! Learn how to structure real-world applications, how to work with the Haskell tool chain effectively, and what to look out for when writing critical sections in the program's logic. Best of all, each project in this book is fully extensible and customizable so you can keep tinkering with your favorites!

About the technology

Programmers spend a lot of time debugging and refactoring code, reading comments and documentation, and trying to make sense out of complex designs. Haskell, a powerful, beautiful, and challenging functional programming language, promises a different path. By focusing your attention on simple functions, clearly-defined behaviors, and the right high-level abstractions, Haskell disallows the dangerous behaviors that usually lead to bugs and crashes.

About the book

Learn Haskell by Example teaches you to build applications in Haskell by designing and coding fun and engaging projects. In this easy-to-follow guide, you’ll create a domain specific language for music, an image processing library, and more! You’ll learn Haskell from the ground-up with a focus on important concepts like function design, composition, and data immutability. Each project gives you a new insight into how to think in Haskell and helps you understand why many Haskell developers say they will never use another language again.

What's insideUse Haskell for daily programming tasksPurely functional programmingAvoid common Haskell pitfalls
About the reader

For readers who know how to program in an object-oriented language.

About the author

Philipp Hagenlocher is a full time Haskell developer, and the creator of the beloved Haskell for Imperative Programmers YouTube course.

The technical editor on this book was Alexander Vershilov.

Table of Contents

1 Introduction
2 Ancient secret keeping on modern machines
3 Every line counts
4 Line numbering tool
5 Words and graphs
6 Solving the ladder game
7 Working with CSV files
8 A tool for CSV
9 Quick checks and random tests
10 Digital music box
11 Programming musical compositions
12 Parsing pixel data
13 Parallel image processing
14 Files and exceptions
15 Transformers for synchronizing
16 JSON and SQL
17 APIs using Servant
Appendix A The Haskell Toolchain
Appendix B Lazy evaluation

456 pages, Paperback

Published November 26, 2024

Loading...
Loading...

About the author

Philipp Hagenlocher

1 book2 followers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
5 (83%)
4 stars
1 (16%)
3 stars
0 (0%)
2 stars
0 (0%)
1 star
0 (0%)
Displaying 1 - 2 of 2 reviews
1 review
February 13, 2025
Despite of, almost all modern mainstream general purpose programming languages contains some sort of elements functional programming, functional programming languages still is not widely accepted by engineers and even Haskell is no exception. At the begging of the book author notes that this book is for programmers and software engineers who already know at least one programming language and want to dip their toes into functional programming with Haskell. He also believes (and I agree) that learning Haskell does not requires you to have Ph.D. in mathematics and this book is the proof of this belief. The structure of this book is very balanced between theory and real-world problem solving. Author gradually introduces to reader Haskell's arsenal to solve real problems. No concept is not introduced without evidence of its significance in concrete cases. This way of learning in my opinion is more effective in most cases. The book starts with how pure functional nature of Haskell deals with correctness and safety, and how can we as engineers benefit using declarative style. There is whole chapter in this about property testing. which is step before formal verification.

In this book reader also can find how useful Haskell is for creating DSLs. In Chapters 10-11 is discussed how to model and program music using Haskell. If you are interested with more about Haskell and music I recommend "The Haskell School of Music: From Signals to Symphonies" by Paul Hudak and Donya Quick.

This book describes how useful are Monads and Applicatives in input parsing (or validating).
"Learn Haskell by Example" is not my first Haskell book. When I started exploring Haskell, I was quite experienced imperative programmer with lot of OOP Design Patterns and idioms in my arsenal. So, I had to unlearn all the your such imperative stuff and learn how Haskell deals same problems. I think, this book will be great companion to experienced engineers who wants to learn Haskell.
1 review
January 6, 2025
(I was asked to read and review this book. I'm a web developer of ~14 years and an intermediate Haskell hobbyist.)

When learning new software languages, tools, and ecosystems, most software engineers I know prefer to dive right in and try to make something practical that they need or want to exist. They like to start out with a project end-goal, get "Hello, world!" out of the way, and chisel away at whatever the problem is until something works, learning and refactoring along the way. However, when it has come to trying to learn Haskell, many engineers I know have lost interest due to getting lost in the (to me, wonderful) depths that the language has to offer.

This book is a game-changer for this vast demographic, though.

Throughout the book, little, easy-to-grok projects are set up as goals, and then the author takes you through the steps of breaking down and solving each problem, sharing anecdotes and the "why?" along the way. Ending each project with simple, neat, functioning code that then gets built on in subsequent chapters means that you keep getting reps in chapter-over-chapter. This author has a knack of engaging you and, before you know it, you take a step back and realize that you've *finally* learned quite a bit of Haskell.

I never thought going from a Caesar cipher to CSVs to musical composition to image processing to JSON & SQL to a web server would be so smooth, but this book does it, and it does it well.

I'll be recommending this to my colleagues who have been bouncing off the surface of Haskell for a while, for its practical approach is just what they need to get started.
Displaying 1 - 2 of 2 reviews