Created
October 23, 2012 17:55
-
-
Save funrep/3940345 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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