2 ms·
I 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
by oconnore 11y ago
I 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