
interact :: (String -> String) -> IO () is a very handy function for
ghc -e, e.g.
ghc -e 'interact $ lines . map (show . (*2) . read) . unlines'
will multiply the number on every line by 2. (interact takes a
function which maps from entire input to entire output)
On 05/11/2007, Graham Fawcett
On Nov 5, 2007 1:46 PM, Maurício
wrote: Hi,
Is there a way to run 'ghc -e' taking input from standard input? I would like to use it in a pipe.
It seems to me that you can use getContents, et. al., as you would from any other Haskell program:
$ echo hello there mauricio | ghc -e "print =<< (Control.Monad.liftM (reverse . words)) getContents" ["mauricio","there","hello"]
G _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe