【发布时间】:2019-04-22 19:01:57
【问题描述】:
这段代码如何
data D = D { _d :: ![P] } -- Note the strictness annotation!
比较一下
newtype D = D { _d :: [P] }
answer to a related question 说:
data 和 newtype 的主要区别在于 data 的构造函数是惰性的,而 newtype 是严格的
当data 版本有严格注解时,这种差异如何发挥作用?
(问题基于我偶然发现的真实代码)
【问题讨论】:
标签: haskell lazy-evaluation newtype