Thinking Functionally with Haskell
A**K
equational reasoning: realizing the dream of algebraic-like manipulation of code
This book is an important landmark in the evolution of Haskell and functional programming.When we speak of “functional” programming, we’re talking about mutation free computation: you can create all the new state you want; but you can’t mutate any existing state.This has a number of advantages that don’t fall on deaf ears these days: one is that mutation free computations are automagically thread safe; which is music to the ears of anyone that’s had to grapple with threading, concurrency, or parallel programming issues.However, another (perhaps more important consideration) is that when we don’t have mutation to worry about, we are free to do substitutions, and manipulate functions (a.k.a. “code”) in algebraic-like ways; and that is the focus of this book. Richard Bird is one of the pioneers of using equational reasoning to refactor existing code and to prove that one code expression is equivalent (or not equivalent) to a different code expression (wherein we are perhaps interested in reliability or improving performance without sacrificing semantic meaning). Or, to prove what a code expression really means; and to thereby be able to generalize it or otherwise reason about it.If you are new to seeing code manipulated in algebraic-like ways, it can seem like black magic until one gets acclimated to thinking about code in a purely functional way; and Haskell, as a programming language, is uniquely suited to that task.This book claims to be a replacement for other works, but it does not cover some material that was covered in past books which I consider very worthwhile.In the way of disclosure I want to mention that I read this book cover to cover (including the index); but did not do any of the exercises (other than to read through them). I also read the following cover to cover: “Introduction to Functional Programming using Haskell second edition” (Bird) and “Algebra of Programming” (Bird, De Moor); both of which I thought were outstanding.One criticism I have of this book is that in the last chapter’s concluding remarks, a pure functional style is recommended over monadic programming (especially when there is no concern about interacting with the outside world). That left me wanting more elaboration: there are many uses of monads; one being to “lift” partial functions to more sophisticated total counterparts (i.e. Maybe). Is there a “purely” functional equivalent for such purposes that is preferable to monads; or is that use of monads perfectly reasonable? (I presume the latter, but would have liked more discussion on the matter.) Also I would have liked to see more examples of how monadic programming can cause difficulties for equational reasoning that can be removed by refactoring to a more purely functional style. A past book did grapple with some negative aspects of monads (like the way they can cause problems when trying to compose them and enforce a coherent order in how things get evaluated). More material on the “sin bin” nature of monads and their potential overuse would be nice.Another comment: I missed the material on bignums; albeit I think the approach taken in a prior publication was flawed because it didn’t “normalize” numbers from least significant (in head position) to most significant (which makes everything much harder, IMO).I hope to see a sequel to this book as the author’s understanding (and the topic itself) evolve.
M**O
Great! Nice to read!
I really enjoyed the reading! I am reading again and redoing the exercises.
K**E
Five Stars
Nice book condition.
B**I
Five Stars
I love it!
P**N
Good self-study book for mature CS aficionados wanting to explore FP or Haskell
This is a very solid introductory textbook on both functional programming and Haskell as a language, and probably among the better ones on either topic -- with the caveat that I haven't read through everything that's on the market, including Bird's own prior textbooks.The text reads smoothly, and is far less dry than Hutton's. This is not necessarily something you're looking for in a textbook, but I found this to be a pleasant departure from the common practice.The approach taken here is heavy on equational reasoning, and the author is not afraid to delve into topics often perceived as arcane -- such as performance optimization of Haskell programs. The book does shy away from discussing rigorous methods for establishing asymptotic complexity under lazy evaluation, but that's probably a good thing in an introductory textbook, and you'd want to refer to Okasaki's PFDS or somesuch for the gory details anyway. Overall, the book takes more of a computer science-y approach, which I find to be slightly preferrable to the alternative "let's start hacking and think about getting out of the mess later" route, though some clever combination of the two might be superior to either.Another win is that the fairly elaborate exercises come with full solutions by the author, printed at the end of each chapter. This makes Thinking Functionally superbly suited for self-study, but probably makes it less appropriate as a basis for a course at a brick-and-mortar school.The book seems to expect a certain degree of mathematical maturity, and may be moving too fast for people without a couple of years of CS, math, EE or similar experience under their belt.I have fairly lukewarm feelings about the book's occasional tendency to borrow features from the future without explaining those, but this doesn't seem like an oversight on the author's part, and more of a principled approach along the lines of "you don't need to understand the details right now, we'll get there eventually, but for now just trust me." I cannot attest whether this works for the target audience or not, as I was fairly familiar with most of the material covered already.Lastly -- and this something of a pet peeve of mine -- I really rather hate the idea of discussing folds without even mentioning unfolds, but oh well. Let's face it, that's all too common anyway, and people live with it somehow. This is just about the only point where Hutton's book does win over Thinking Functionally.
K**H
A Classic which makes you feel ambivalent
Superb and unique introduction, but not for beginners.It shows you what is THE functional programming, but doesn't teach you how to do it.Decent and inspiring, and not explaining much.Anyway, You should read it. It tells you things which you wouldn't hear anywhere else.But the problem is "What Next?". Yeah, There is no royal road.
T**R
Book printed on tissue-thin paper is extremely difficult to read
This is a very difficult book to read, physically. The publisher has chosen such thin inexpensive paper that printing from the reverse side of the page -always- intrudes (in reverse black blobs) on every single page you're trying to read. This is very distracting and makes the book a trial to read. It's a shame that Cambridge University Press has chosen such a cheap-skate route because it's clear this book has much to offer. And just for a few pennies. Shame.
P**K
Book does help you start with Haskell but doesn't help ...
Book does help you start with Haskell but doesn't help you see things functionally till later chapters in the bookIn my opinion "Real World Haskell" manages expectation well
Trustpilot
3 days ago
2 weeks ago