在哈斯克尔工作,发现奇怪的行为,将其剥离为裸骨
这个作品
a :: Bool
a = case True of
True -> True
False -> False
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试
b :: IO Bool
b = do
let b' = case True of
True -> True
False -> False
return b'
Run Code Online (Sandbox Code Playgroud)
我明白了
ghci>:l test.hs
[1 of 1] Compiling Main ( test.hs, interpreted )
test.hs:16:14: parse error on input ‘->’
Failed, modules loaded: none.
Run Code Online (Sandbox Code Playgroud)
所以我试试
c :: IO Bool
c = do
let c' = case True of
True -> True
False -> False …Run Code Online (Sandbox Code Playgroud)