Alan
Alan

Reputation: 9620

How can I write an IO [String] to stdout?

I have an IO [String] in main, which I want to write (as lines) to stdout. How?

--newbie

Upvotes: 1

Views: 85

Answers (1)

Thomas M. DuBuisson
Thomas M. DuBuisson

Reputation: 64740

IO [String] is an action that will get you strings. If you wish to perform the action and print the results then consider:

printIOString io = putStrLn . unlines =<< io

Or with some additional notation, if you prefer:

printIOString io =
  do strs <- io
     let rendered = unlines strs
     putStrLn rendered

Upvotes: 9

Related Questions