我正在學習learnyouhaskell.com的Haskell,並在編譯我的程序時收到此錯誤消息。Haskell - 由於使用製表符而不是空格的語法錯誤
錯誤:
baby.hs:25:26: error:
parse error on input `='
Perhaps you need a 'let' in a 'do' block?
e.g. 'let x = 5' instead of 'x = 5'
代碼:
bump :: [String] -> IO()
bump [fileName, numberString] = do
handle <- openFile fileName ReadMode
(tempName, tempHandle) <- openTempFile "." "temp"
contents <- hGetContents handle
let number = read numberString
text = lines contents
bumpLine = text !! number
newText = delete (text !! number) text
hPutStr tempHandle $ unlines (bumpLine:newText)
hClose handle
hClose tempHandle
removeFile fileName
renameFile tempName fileName
誰能幫助我?
這可能是一個製表符問題。嘗試刪除縮進的製表符並改爲使用空格。 – Bakuriu
@Bakuriu我證實了這是一個選項卡問題 - 在let表達式後的縮進必須與空格(此外它是混合標籤/空格) - 我想你的評論將是答案(我不會' t已經發現過) – epsilonhalbe
謝謝。現在它工作。是否有任何解決方案使用與選項卡字符的哈斯克爾? –