0
因为添加一个int的功能,我们可以看到它的类型签名:如何读取Haskell中的函数类型签名?
Prelude> addOne :: Int -> Int; addOne x = x + 1
Prelude> :t addOne
addOne :: Int -> Int
的签名意味着addOne接受一个int并返回一个int。够简单。而是如果我们定义没有指定类型的函数:
Prelude> anotherAddOne x = x + 1
Prelude> :t anotherAddOne
anotherAddOne :: Num a => a -> a
它使现在我们正在处理Num
不Int
但什么方式来读取Num a => a -> a
有意义吗? =>
和->
这里有什么区别?