您的位置:首页 > 编程语言 > Go语言

[Learning You a Haskell for Great Goods!] chapter 02 believe the type

2014-09-24 14:48 417 查看
Haskell has type inference

function declaration

methodname :: [input type] -> [return type]

or

methodname :: [input type] -> [input type] -> [input type] -> [return type]

check type

ghci> :t 'a'

'a' :: Char

ghci> :t (+)

(+) :: Num a => a -> a -> a

class constraint

show & read

ghci> :t show

show :: Show a => a -> String

ghci> :t read

read :: Read a => String -> a

ghci> read "5" :: Int

5

if haskell could interfer the type , then no need to declaration
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐