5 ms·
How laziness changes thinking in Haskell
- snprbob86 18y agoI'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?
- felixmar 18y agoIf 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.
- miloshh 18y agoI 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 http://www.haskell.org/haskellwiki/Stack_overflow
- T_S_ 18y agoThe 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 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.
- Deestan 18y agoYour link is missing the ' at the end. http://www.haskell.org/haskellwiki/Foldr_Foldl_Foldl%27 http://www.haskell.org/haskellwiki/Foldr_Foldl_Foldl%27
- noamsml 18y ago"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.")
- ionfish 18y agoThere 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 http://users.aber.ac.uk/afc/stricthaskell.html