Haskell 中“putStrLn”的基本错误。 VScode 扩展 Haskelly
Basic error with `putStrLn` in Haskell. VScode extension Haskelly
main = do line <- getLine
let line' = reverse line
putStrLn $ "You said " ++ line' ++ " backwards!"
putStrLn $ "Yes, you really said " ++ line ++ " backwards!"
错误:
$ stack runhaskell "c:\Users\FruitfulApproach\Desktop\Haskell\test.hs"
C:\Users\FruitfulApproach\Desktop\Haskell\test.hs:4:5: error:
parse error on input `putStrLn'
|
4 | putStrLn $ "You said " ++ line' ++ " backwards!"
| ^^^^^^^^
我也尝试过在缩进行上使用单个制表符。
这是我的制表符 -> 空格设置:
我也试过重新启动 VSCode。
提前致谢!
我认为您的代码缩进不够。试试这个:
main = do line <- getLine
let line' = reverse line
putStrLn $ "You said " ++ line' ++ " backwards!"
putStrLn $ "Yes, you really said " ++ line ++ " backwards!"
具体来说,do
之后的行应与其后的行一样缩进,即 line <- getLine
.
main = do line <- getLine
let line' = reverse line
putStrLn $ "You said " ++ line' ++ " backwards!"
putStrLn $ "Yes, you really said " ++ line ++ " backwards!"
错误:
$ stack runhaskell "c:\Users\FruitfulApproach\Desktop\Haskell\test.hs"
C:\Users\FruitfulApproach\Desktop\Haskell\test.hs:4:5: error:
parse error on input `putStrLn'
|
4 | putStrLn $ "You said " ++ line' ++ " backwards!"
| ^^^^^^^^
我也尝试过在缩进行上使用单个制表符。
这是我的制表符 -> 空格设置:
我也试过重新启动 VSCode。
提前致谢!
我认为您的代码缩进不够。试试这个:
main = do line <- getLine
let line' = reverse line
putStrLn $ "You said " ++ line' ++ " backwards!"
putStrLn $ "Yes, you really said " ++ line ++ " backwards!"
具体来说,do
之后的行应与其后的行一样缩进,即 line <- getLine
.