Haskell编译器错误:不在范围内

Haskell编译器错误:不在范围内,haskell,Haskell,我试图通过编写一个简单的文件副本来学习haskell: main = do putStr "Source: " srcPath <- getLine putStr "Destination: " destPath <- getLine putStrLn ("Copying from " ++ srcPath ++ " to " ++ destPath ++ "...") con

我试图通过编写一个简单的文件副本来学习haskell:

main = do
         putStr "Source: "
         srcPath <- getLine
         putStr "Destination: "
         destPath <- getLine
         putStrLn ("Copying from " ++ srcPath ++ " to " ++ destPath ++ "...")
         contents <- readFile srcPath
         writeFile destPath contents
         putStrLn "Finished"
我不理解编译器的错误,因为变量似乎正常。怎么了


这是一个复制文件:

,看起来很正确。我只是将其粘贴到一个.hs文件中,并:将其加载到GHCi中。在这里工作,我有与您相同的GHC版本。

看起来您混合了选项卡和空格(只需在“编辑”视图中查看您的问题即可查看问题)。当编辑器查看均匀缩进的代码时,编译器似乎对选项卡的宽度有不同的解释,导致
writeFile destPath contents
行额外缩进。因此,对来源的解释如下:

  ...
  putStrLn ("Copying from " ++ srcPath ++ " to " ++ destPath ++ "...")
  contents <- readFile srcPath writeFile destPath contents
  putStrLn "Finished"
。。。
putStrLn(“从“++srcPath++”复制到“++destPath++”…”)

我上传了我使用的hs文件的内容。
  ...
  putStrLn ("Copying from " ++ srcPath ++ " to " ++ destPath ++ "...")
  contents <- readFile srcPath writeFile destPath contents
  putStrLn "Finished"