O'Reilly logo

Haskell Design Patterns by Ryan Lemmer

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 6. Patterns of Generic Programming

In this chapter, we seek a unified view of "Generic Programming", which comes in many guises; hence the statement,

 

"Genericity is in the eye of the beholder"

 
 --Jeremy Gibbons, Datatype-Generic Programming

We start with a broad perspective by reviewing Jeremy Gibbons' patterns of generic programming—many of which we have already encountered. Then we shift focus to one of the patterns—datatype-generic programming—which is characterized by generic functions parameterized by the shape of the datatype instead of the content.

To get a taste of datatype-generic programming, we'll sample three basic approaches: the sum of products, origami programming, and scrap your boilerplate.

Along the way, we'll encounter ...

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