[Haskell-cafe] ghc -e with standard input
Rodrigo Queiro
overdrigzed at gmail.com
Mon Nov 5 15:10:36 EST 2007
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 <graham.fawcett at gmail.com> wrote:
> On Nov 5, 2007 1:46 PM, Maurício <briqueabraque at yahoo.com> 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 at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
More information about the Haskell-Cafe
mailing list