Time cost of Haskell `seq` operator

前端 未结 5 1154
逝去的感伤
逝去的感伤 2021-02-13 22:32

This FAQ says that

The seq operator is

seq :: a -> b -> b

x seq y will evaluate x, enough to chec

5条回答
  •  醉梦人生
    2021-02-13 23:31

    The seq function will discard the value of x, but since the value has been evaluated, all references to x are "updated" to no longer point to the unevaluated version of x, but to instead point to the evaluated version. So, even though seq evaluates and discards x, the value has been evaluated for other users of x as well, leading to no repeated evaluations.

提交回复
热议问题