I began to study Haskell and felt overcrowded. Now I'm trying to create a function that returns a string from standard input or from the contents of a list of files. In other words, I am trying to replicate the behavior of a Unix wc utility that accepts input from stdin when no files are specified.
I created something like this:
parseArgs [] = [getContents] parseArgs fs = mapM readFile fs
But it does not compile, because in one case I have [IO String] and in the other IO [String]. I cannot make this template suitable for returning IO [String] in all cases. Please point me in the right direction.
io haskell monads
Valentin
source share