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

Chapter 14Haskell Hands-On

by Paul Callaghan

The preceding chapter was a glimpse into the mindset of an experienced Haskell programmer. Now it’s time to do some programming. Let’s try a kata.

We’re going to use Dave Thomas’s word-chain kata,[7] and through it we’ll explore how functional programmers approach a problem, we’ll learn some Haskell syntax and libraries, and we’ll touch on performance and optimization of Haskell code.

The objective of the kata is to find a series of steps from one word to another, where in each step a single letter is changed such that the resulting string is also a valid word. For example, turning “lead” into “gold” with the path ["lead", "load", "goad", "gold"]. For simplicity, I’ll assume four-letter words ...

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