[Haskell-cafe] Strictness in do block
John Goerzen
jgoerzen at complete.org
Wed Jul 5 07:04:22 EDT 2006
Hi,
One thing that seems to keep biting me is strictness in do blocks.
What I want to know is the generic way to force an entire String (or
other list, perhaps from hGetContents) to be evaluated (read into RAM, I
guess) so the underlying file can be closed.... and do it right now.
One quick hack that works is hPutStrLn on it, right where I want it to
be evaluated. But ugly and not always appropriate. Passing it to some
other IO-based functions also works, but again, that doesn't "feel"
right.
I can always stumble upon things that work, but I'm never sure if I've
got 'em right. So, what is the idiomatic way to do this?
Most of the documents I see out there on this topic are for usage
outside the I/O monad, and I'm not seeing how they apply here.
Thanks,
-- John
More information about the Haskell-Cafe
mailing list