I am completely newbie in Haskell and reading tutorial I have found something like that
Thanks to Haskell's laziness, even if you map something over a list several times and filter it several times, it will only pass over the list once.
That's my simple stupid example: x = map foo (map foo [1,2]) where foo p = p * 2
Now, to my mind came two questions.
- Why is it thanks to laziness? I know that laziness means that it does not evaluate expression till it has to but... How does it force iterating list once instead of declared number of maps/filters?
- How can I verify that it iterates only once?
- Bonus question - I know that side effections are