Skip to Content
Effective Haskell
book

Effective Haskell

by Rebecca Skinner
July 2023
Intermediate to advanced
670 pages
17h 13m
English
Pragmatic Bookshelf
Content preview from Effective Haskell

Destructuring Values with Pattern Matching

In the last section, as you worked with lists, you learned how the shape of a list was reflected in the way you worked with it using functions like (:), head and tail. The idea that the shape of a data structure can be reflected in how we write code to use that data structure is a powerful one, and it turns out to have much more broad-reaching applicability than just lists.

Using pattern matching lets you write powerful expressions that match parts of a value based on its shape. You’ll learn several ways to use pattern matching in the remainder of this chapter. Let’s start by looking at how you can use pattern matching with functions, case statements, and let bindings.

In its simplest form, a pattern ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Grokking Functional Programming

Grokking Functional Programming

Michal Plachta
Grokking Algorithms

Grokking Algorithms

Aditya Bhargava
The Rust Programming Language, 2nd Edition

The Rust Programming Language, 2nd Edition

Steve Klabnik, Carol Nichols

Publisher Resources

ISBN: 9798888650400Errata Page