未提升型产品的缺点? [英] Disadvantage of unlifted type products?
问题描述
所有产品的所有模式匹配总是无可辩驳的,那么就没有区别,并且(a,b,c)可能是(a,(b,c))的语法糖。
为什么Haskell选择提升类型产品?一个原因是,执行 因为
当且仅当 seq(a,b)True
应该是,所以对于未提升的产品,seq
需要并行/交错计算。 True a
和 b
中至少有一个是非底部的。根据你对 seq
的看法,你可能不会发现这种说法非常令人信服,但当然多态性 seq
是由定义Haskell的一部分......
In Haskell, lifted type products mean that there's a semantic difference between (a,b,c) and (a, (b, c)).
If all pattern matches of all products was always irrefutable, then there would be no difference, and (a, b, c) could be syntactic sugar for (a, (b, c)).
Why did Haskell choose to lift type products?
One reason is that implementing seq
for an unlifted product requires parallel/interleaved computation, since seq (a, b) True
would be supposed to be True
if and only if at least one of a
and b
is non-bottom. You might not find this reason terribly convincing, depending on how you feel about seq
, but of course polymorphic seq
is by definition a part of Haskell...
这篇关于未提升型产品的缺点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!