haskell 趣学指南笔记-1type and typeclass

来源:互联网 发布:儿童编程培训加盟 编辑:程序博客网 时间:2024/05/14 21:39

几个type 类型

Int 有界

Integer无界,效率低于Int

Float

Double

Bool

Char

几个typeclass 类型

:t (==)

(==)::(Eq a)=>a->a->Bool

Eq class:提供了判断相等性的接口,凡是可比较相等性的类型必属于 Eq class,==和/=操作

Ord class: 比较大小操作,<,>,>=,=<.

Show class:类型为可用字符串表示的类型

Read class :是与Show类型相反的类型。可将字符串转换成某种类型。

Enum class :枚举类型

Boarded: 上下界类型

Num class :数字类型

Integral class: 同样是表示数字的 Typeclass。Num 包含所有的数字:实数和整数。而 Intgral 仅包含整数,其中的成员类型有Int 和 Integer  

Floating class: 仅包含Float 和Double