Taking Notes from http://learnyouahaskell.com
Type
|
|
Function Type
|
|
Types
Int
有界的整数Integer
无界的Float
单精度的浮点数Double
双精度的浮点数Bool
True FalseChar
Tuple
Type Variables
a 是类型变量, type variable
Typeclasses
|
|
Eq
判断相等性的接口elem :: (Eq a) => a -> [a] -> Bool
Ord
包含可比较大小的类型. Ord 包中包含了<, >, <=, >= 和 compare 函数.
Compare 返回 GT, LT, EQ
Show
Show 的成员为可用字符串表示的类型
Read
read 函数可以将一个字符串转为 Read 的某成员类型
Enum
Enum的成员都是连续的类型 – 也就是可枚举
Enum 包含的类型有:(), Bool, Char, Ordering, Int, Integer, Float 和 Double
succ (successer)函数和 pred (predecesor)函数
Bounded
成员都有一个上限和下限
Num
表示数字的 Typeclass. Num 包含所有的数字:实数和整数
类型只有亲近 Show 和 Eq,才可以加入 Num
Integral
Integral 仅包含整数,其中的成员类型有 Int 和 Integer
Floating
仅包含浮点类型:Float 和 Double
fromIntegral
它取一个整数做参数并回传一个更加通用的数字fromIntegral :: (Num b, Integral a) => a -> b