Re:The Haskell user experience
by AnimalMuppet on Wednesday August 05, 2015 @11:47AM
(#10010612)
Is it fair to say that in Haskell, you have to think about evaluation order less, but when you do, it's harder?
[ Parent
| on HN ]
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
Re:The Haskell user experience
by jonnybgood on Wednesday August 05, 2015 @12:16PM
(#10010828)
When you hit that difficult to reason about evaluation order in Haskell, it'll take that time you thought you gained.