问题在于找出每个学习Haskell的人应该注意的最佳功能。
答案 0 :(得分:3)
要记住的最重要的事情是懒惰。在被迫之前,没有任何东西被评估。例如,Haskell没有像你在C-ish语言中看到的那样的三元运算符,但你可以将它自己编写为一个简单的函数。
infixl 1 ?
(?) :: Bool -> a -> a -> a
(?) True = const
(?) False = const id
main = 1 == 2 ? putStrLn "Oh no, the world is ending!" $ putStrLn "OK, math still works"
-- Only prints "OK, math still works"