Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
-- InteractWith.hs
-- From Real World Haskell Chapter 04

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