相关疑难解决方法(0)

let语句中的case语句需要什么缩进?

在哈斯克尔工作,发现奇怪的行为,将其剥离为裸骨

这个作品

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)

haskell indentation do-notation

9
推荐指数
2
解决办法
1996
查看次数

标签 统计

do-notation ×1

haskell ×1

indentation ×1