Archive for May 16th, 2009

Real World Haskell: Chapter 3

Saturday, May 16th, 2009

Real World Haskell Chapter 3 is your introduction to the real syntax of Haskell programs.  It’s not entirely complete yet (you need modules and a few other things), but it’s enough to write one-purpose scripts, which is a huge step.

Again, there wasn’t all that much new to me in Chapter 3 here.  The important thing to takeaway was a review of the difference between data and type: data is struct, type is typedef (with type safety).  Other than that, the coverage of guards was nice, and the exercises were good for reinforcing knowledge and expanding horizons a little bit. Ending with the Graham scan algorithm is a little intense, but it’s significantly less evil than some of Knuth’s high-numbered problems.

However, in the exercises, be wary of number 4: there was a ++ operator introduced in the context of strings.  Don’t forget that it exists.  Number 5 is also a bit gnarly; I feel like they’ve totally screwwed the pooch on it.  If you don’t get it within 10 minutes, give up and read the comments on the website (or, if you know a bit about the performance of Lists in functional languages, just accept that your solution is O(n2)).