我試圖通過編寫一個簡單的文件複製UTIL學習哈斯克爾: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"
這讓我
GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main (D:\Test.hs, interpreted)
D:\Test.hs:8:22: Not in scope: `contents'
Failed, modules loaded: none.
Prelude>
我不明白,編譯器錯誤,因爲該變量似乎是確定的。哪裏不對?
這裏是一個攝製文件:at rapidshare
我上傳了我使用的hs文件。 – usr 2009-11-07 19:22:45