Skip to content

Comment on The Haskell user experienceparent

Comments

Is it fair to say that in Haskell, you have to think about evaluation order less, but when you do, it's harder?

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

When you hit that difficult to reason about evaluation order in Haskell, it'll take that time you thought you gained.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.