November 2015
Intermediate to advanced
166 pages
3h 14m
English
The history of Haskell is deeply entwined with the history of lazy evaluation.
"Laziness was undoubtedly the single theme that united the various groups that contributed to Haskell's design... Once we were committed to a lazy language, a pure one was inescapable." | ||
| --History of Haskell, Hudak et al | ||
Thanks to lazy evaluation, we can still consume the undoomed part of this list:
doomedList = [2, 3, 5, 7, undefined] take 0 xs = [] take n (x:xs) = x : (take (n-1) xs) main = do print (take 4 doomedList)
The take function is lazy because the cons operator (:) is lazy (because all functions in Haskell are lazy by default).
A lazy cons evaluates only its first argument, while the second argument, the tail, is only evaluated when it is selected. ...
Read now
Unlock full access