Changes

 

What has changed from the second edition?


The third edition has seen changes throughout. Material, particularly by way of new examples, has been added to every chapter, and the order of presentation has changed in response to feedback on the previous edition. In detail the changes are these:


QuickCheck is used throughout to test Haskell functions. Properties are developed right from the start, and QuickCheck is used to verify them - or indeed to show that properties can be erroneous too. HUnit is also introduced, but is used less intensively.


QuickCheck is presented as complementary to proof, which has always been included in the book: QuickCheck can provide strong evidence for a property holding, while proof can establish its validity. Some custom generators are supplied in the code base for the book so that programmers can test their code before the details of how generators are defined are discussed in Chapter 19.


A number of new examples have been included, some in a single place and others running through a number of chapters. These include the Rock - Paper - Scissors (RPS) game, card games in general, an SVG rendering of Pictures and regular expression. There is a particular emphasis on using functions as data: they appear as strategies in RPS and as recognisers for regular expressions.


One area where Haskell has been particularly successful is in providing the substrate for developing embedded domain-specific languages (DSLs) and Chapter 19 is devoted to this. It begins by explaining the reasons for developing DSLs, and then examines the difference between shallow and deep embeddings, looking at the examples of pictures and regular expressions. It concludes with a discussion of monadic DSLs, exemplified by naming in a pictures DSL and by the generators of QuickCheck.


The text has been reordered so that some material comes earlier than it did previously. Material on data types comes substantially earlier, with enumerated types coming into Section 4.3 and non-recursive types into Section 5.3. Programming for IO interactions is introduced in Chapter 8 to support the Rock - Paper - Scissors example: this treatment simply presents the do notation as the way that IO is programmed, and delays an explanation of the underlying mechanism to Chapter 18. Finally, local definitions first come into Section 4.2.


The second edition used Hugs as its preferred implementation; in this edition we have moved to using GHCi, which comes as a part of the Haskell Platform. As well as introducing GHCi, we have added detailed discussions of how to leverage the best from Haskell libraries and packages through using Hackage, Cabal, Hoogle and Hayoo!


A realistic implementation of pictures -- using the SVG / HTML5 capabilities of modern web browsers -- has been added to the `ASCII art' implementation of the second edition.


The discussions in Chapter 20 on performance have been supplemented with material on how to measure the performance of real programs in GHC.


A collection of project suggestions has been added as an appendix. Further support materials are available here, and solutions to exercises are available to bona fide instructors by application to the publishers.