What are Haskell's strictness points?

前端 未结 8 1289
伪装坚强ぢ
伪装坚强ぢ 2021-01-29 22:00

We all know (or should know) that Haskell is lazy by default. Nothing is evaluated until it must be evaluated. So when must something be evaluated? There are points where Haskel

8条回答
  •  忘了有多久
    2021-01-29 22:41

    Lazy doesn't mean do nothing. Whenever your program pattern matches a case expression, it evaluates something -- just enough anyway. Otherwise it can't figure out which RHS to use. Don't see any case expressions in your code? Don't worry, the compiler is translating your code to a stripped down form of Haskell where they are hard to avoid using.

    For a beginner, a basic rule of thumb is let is lazy, case is less lazy.

提交回复
热议问题