未提升型产品的缺点? [英] Disadvantage of unlifted type products?

查看:83
本文介绍了未提升型产品的缺点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Haskell中,提升类型产品意味着(a,b,c)和(a,(b,c))之间存在语义差异。

所有产品的所有模式匹配总是无可辩驳的,那么就没有区别,并且(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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆