Haskell中`putStrLn`的基本错误。 VScode扩展Haskelly [duplicate]

问题描述 投票:0回答:1
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!"
  |     ^^^^^^^^

我也尝试过使用缩进行上的单个选项卡。

这是我的标签->空格设置:

tabs to spaces setting screenshot

我也尝试过重新启动VSCode。

提前感谢!

haskell visual-studio-code haskell-stack
1个回答
5
投票

我相信您的代码缩进不足。试试这个:

main = do line <- getLine
          let line' = reverse line
          putStrLn $ "You said " ++ line' ++ " backwards!"
          putStrLn $ "Yes, you really said " ++ line ++ " backwards!"

特别是,紧随do的行应缩进,紧随其后的内容line <- getLine

© www.soinside.com 2019 - 2024. All rights reserved.