[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
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
相关文章推荐
- [Learning You a Haskell for Great Goods!] chapter 01 starting out
- [Learning You a Haskell for Great Goods!] Introduction
- [2017.02.21-22] 《Haskell趣学指南 —— Learning You a Haskell for Great Good!》
- jQuery Lint: enables you to automatically inject jQuery Lint into the page as it is loaded (great for ad-hoc code validation)
- You have an error MySQL server version for the right syntax to use near 'TYPE=InnoDB' at line 20
- Learning Data Binding with Windows Forms 2.0(1)-The Quest for Type Safety
- 《Haskell趣学指南 Learn You a Haskell for Great Good!》-代码实验
- The method setStatus(int) in the type Goods is not applicable for the arguments (Integer)
- Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You
- We're on the cusp of deep learning for the masses. You can thank Google later
- 当打开SLN文件出现 Make sure the application for the project type () is installed. 的原因。
- The Business Case for E-Learning
- The Run-time Type Information library for the Pocket PC 2003 SDK is available
- The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory!
- Linux Annoyances for Geeks : Getting the Most Flexible System in the World Just the Way You Want It
- The SQL Site Map Provider You've Been Waiting For
- Jump for the sun at least you land on the moon
- 地震前的准备工作(Get prepared for the possility of a great earthquake)
- JBOSS部署:The method getJspApplicationContext(ServletContext) is undefined for the type
- 故障解决:Failure adding assembly to the cache: Access denied. You might not have administrative credentials to perform this task. Contact your system administrator for assistance.