Hacker News new | past | comments | ask | show | jobs | submit login
How laziness changes thinking in Haskell (newartisans.com)
15 points by mqt on March 24, 2009 | hide | past | favorite | 7 comments



The example given in the article can be addressed by using foldl' instead of foldr. The issue is discussed in

http://www.haskell.org/haskellwiki/Foldr_Foldl_Foldl

A Haskell programmer needs to understand when non-strict evaluation can/should be avoided. foldr is usually more elegant but sometimes less efficient.


Your link is missing the ' at the end.

http://www.haskell.org/haskellwiki/Foldr_Foldl_Foldl%27


I've read a whole lot about Haskell, but still haven't fired up ghc for fear of spending too much time playing with it. This post makes me even more interesting to play with it, but even more scared that I will like it. I'm afraid that I will like it because I am afraid I will run into stuff like this when it is too late.

Unrelated comment: do any other Haskell fans know of a solution or debugging strategies for this problem?


If you have the spare time think of learning Haskell as a great learning experience. Haskell's concepts are imho worth your time and are useful to know when programming in other languages. It is a cliché but i do think learning Haskell has made me a better programmer.

Haskell's laziness is at times surprisingly cool but will also remain tricky. I sometimes compare it with lock based multi-thread programming. It can be done but also requires additional thought.


I think you will run into problems like this pretty early on, and no worry, they're all fixable. :) The other links in this discussion are good, and here's another one: http://www.haskell.org/haskellwiki/Stack_overflow


There are a number of useful tips in this article about when, and how, to use strict evaluation in Haskell.

http://users.aber.ac.uk/afc/stricthaskell.html


"Ugh, I'm too tired to learn Haskell. Maybe another day."

That kind of laziness? (I kid, I kid, we all know it's "I'll learn Haskell only when I have to compute something which requires me to know it. I mean, I thunk I know it.")




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: