Why do we need 'seq' or 'pseq' with 'par' in Haskell?

后端 未结 3 1545
我在风中等你
我在风中等你 2021-02-02 08:33

I\'m trying to understand why we need all parts of the standard sample code:

a `par` b `pseq` a+b

Why won\'t the following be sufficient?

3条回答
  •  醉梦人生
    2021-02-02 09:23

    a `par` b `par` a+b 
    

    will evaluate a and b in parallel and returns a+b, yes.

    However, the pseq there ensures both a and b are evaluated before a+b is.

    See this link for more details on that topic.

提交回复
热议问题