我有很多代码的风格:
do
x <- getSomething
case x of
this -> ...
that -> ...
other -> ...
Run Code Online (Sandbox Code Playgroud)
我将"x < - ..."和"case x of"行组合在一起以消除对变量的需求吗?
您可以使用bind运算符>>=
来管道x
.
import System.Environment (getArgs)
main :: IO ()
main = getArgs >>= process
where process ["xxx"] = putStrLn "You entered xxx"
process ["yyy"] = putStrLn "You entered yyy"
process _ = putStrLn "Error"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
334 次 |
最近记录: |