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
Post a Comment