[Learning You a Haskell for Great Goods!] chapter 02 believe the type
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
浙公网安备 33010602011771号