Skip to content

Instantly share code, notes, and snippets.

@funrep
Created October 23, 2012 17:55
Show Gist options
  • Save funrep/3940345 to your computer and use it in GitHub Desktop.
Save funrep/3940345 to your computer and use it in GitHub Desktop.
-- file: ch04/InteractWith.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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment