pipe - Redirect last action's stdout using >>= in haskell -


how can output previous action , print using >>= in haskell?

in shell, like,

echo "hello world" | { read test; echo test=$test; } 

in haskell, looking like,

putstrln "hello world" >>= {x <- getargs; print x} 

getargs stdin must take input putstrln's stdout.

edit#1, alexey & aochagavia, inputs. works.

x :: io string x = return "hello world"  main =   x >>= print 

no, >>= doesn't have stdout. can use capture_ function silently package:

 x <- capture_ (putstrln "hello world")     print x 

or capture_ (putstrln "hello world") >>= print.


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -