File processing-Haskell
- by Martinas Maria
How can I implement in haskell the following: I receive an input file from the command line.
This input file contains words separated with tabs,new lines and spaces.I have two replace this elements(tabs,new lines and spaces) with comma(,) .Observation:more newlines,tabs,spaces will be replaced with a single comma.The result has to be write in a new file(output.txt).
Please help me with this.My haskell skills are very scarse.
This is what I have so far:
processFile::String->String
processFile [] =[]
processFile input =input
process :: String -> IO String
process fileName = do
text <- readFile fileName
return (processFile text)
main :: IO ()
main = do
n <- process "input.txt"
print n
In processFile function I should process the text from the input file.
I'm stuck..Please help.