O'Reilly logo

Learn You a Haskell for Great Good! by Miran Lipovaca

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Syntax in Functions

In this chapter, we’ll take a look at the syntax that enables you to write Haskell functions in a readable and sensible manner. We’ll look at how to quickly deconstruct values, avoid big if else chains, and store the results of intermediate computations so that you can reuse them multiple times.

Pattern Matching

Pattern matching is used to specify patterns to which some data should conform and to deconstruct the data according to those patterns.

image with no caption

When defining functions in Haskell, you can create separate function bodies for different patterns. This leads to simple, readable code. You can pattern match on pretty much any ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required