3 ms·
Is it fair to say that in Haskell, you have to think about evaluation order less, but when you do, it's harder?
by AnimalMuppet 11y ago
Is it fair to say that in Haskell, you have to think about evaluation order less, but when you do, it's harder?
- jonnybgood 11y agoWhen you hit that difficult to reason about evaluation order in Haskell, it'll take that time you thought you gained.
- oconnore 11y agoI think it can be unexpected if you're used to other semantics, but the behavior of laziness is very well defined. > let x = [1 .. 100] :: [Int] > seq x () -- force the first cons > :sprint x x = 1 : _ -- we evaluated the first cons > foldr (\e l -> e + l) 0 x 5050 -- printing this value forces foldr to complete > :sprint x x = [1,2,3,4,5...100] -- all conses evaluated