2

「Real World Haskell」のコードを書いています:

 ghc --make ch04/InteractWith.hs 
[1 of 1] Compiling Main             ( ch04/InteractWith.hs, ch04/InteractWith.o )

ch04/InteractWith.hs:9:5: parse error on input `args'

dan@dbmint ~/testHaskell $ 猫 ch04/InteractWith.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"

myFunction = id
4

2 に答える 2

2

空白はオフです

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"

myFunction = id
于 2013-09-04T00:11:00.180 に答える