Seems similar to this: How to implement a transcript program in Haskell? - #2 by tomjaguarpaw
If I came up against this problem I would look really hard for a way to rewrite main :: IO () into something yields its output into an iterator/pipe/conduit. Would that be possible in your case?