Haskell类Num不包含在Ord中? [英] Haskell class Num not contained in Ord?

查看:115
本文介绍了Haskell类Num不包含在Ord中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读 LYAH 并阅读Num类不是Ord的子集。这意味着有一个Num类型不是Ord的成员,可以构成这样一个类型?

I was reading LYAH and read that the Num class isn't a subset of Ord. This means that there is a Num type which is not a member of Ord, what could constitute such a type?


注意:Num不是Ord的一个子类。这意味着对于一个数字来说,构成
的东西并不一定要遵循一个顺序。所以这就是
,为什么当
做加法或减法以及比较时,我们必须指定Num和Ord类的约束。

Note: Num is not a subclass of Ord. That means that what constitutes for a number doesn't really have to adhere to an ordering. So that's why we have to specify both the Num and Ord class constraints when doing addition or subtraction and also comparison.

谢谢!

Thanks!

推荐答案

复杂数字(Data.Complex.Complex)就是一个例子,它是一个数字(Num),但不能排序(不是Ord)。

Complex number (Data.Complex.Complex) is one example which is a number (Num) but cannot be ordered (not Ord).

这篇关于Haskell类Num不包含在Ord中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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