O'Reilly logo

Functional Programming: A PragPub Anthology by Michael Swaine

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

Data Types Are Cheap

As I said at the outset (and will say again), all we did here was to identify the kinds of data we had in the problem domain, and what kinds of transformations we wanted to perform on it, and then we built up the data structures and the code to do the transformations.

Let’s look at the tools that modern functional languages provide for doing this.

The first “tool” is the sheer flexibility for declaring new data types and the scope for reusing them. This is very important: rather than encoding some data in a hash and hoping that you remember to keep the encoding consistent, Haskell allows—even encourages—you to add a new type that expresses exactly what you want to store. Such type declarations are much shorter than the ...

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