Code from 'Haskell - the craft of functional programming'