不知道为什么使用WinGHCi 1.0.6获取Haskell"<interactive>:48:1:输入'.''解析错误"

Fra*_* D. 0 haskell

我是Haskell中的新手,运行在Haskell下面的代码,第4章是RealWorld Haskell Book并获得

 <interactive>:48:1: parse error on input ‘./’
Run Code Online (Sandbox Code Playgroud)

这是我在WinGHCi 1.0.6上执行的

Prelude> :load Interact    
[1 of 1] Compiling Main             ( Interact.hs, interpreted )    
Ok, modules loaded: Main.    
*Main> --make Interact    
*Main> :load Interact    
[1 of 1] Compiling Main             ( Interact.hs, interpreted )    
Ok, modules loaded: Main.    
*Main> ./Interact "infrank.txt" "outfrank.txt"    
    *<interactive>:48:1: parse error on input ‘./’*
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?因为我试图谷歌周围没有希望

以下是RealWorld Haskell第4章的代码

-- file: ch04/Interact.hs    
-- Save this in a source file, e.g. Interact.hs

import System.Environment (getArgs)
interactWith function inputFile outputFile = do

  input <- readFile inputFile    
  writeFile outputFile (function input)

main = mainWith myFunction
  where mainWith function = do

          args <- getArgs
          case args of
            [input,output] -> interactWith function input output
            _ -> putStrLn "error: exactly two arguments needed"

        -- replace "id" with the name of our function below
        myFunction = id
Run Code Online (Sandbox Code Playgroud)

Sib*_*ibi 5

我只看了第4章,你似乎在ghci提示符和shell(在Windows情况下为cmd.exe)之间感到困惑.

您必须在shell(对于Unix系统)或cmd.exeWindows中运行此命令:

ghc --make Interact.hs
./Interact "infrank.txt" "outfrank.txt"
Run Code Online (Sandbox Code Playgroud)

这本书似乎也有一些错误,因为他们正在生成一个名为InteractWithusing 的可执行文件ghc --make InteractWith,然后使用Interact而不是InteractWith.