[Haskell] writeFile for a looong string

Johannes Waldmann waldmann at imn.htwk-leipzig.de
Thu Jul 14 05:07:58 EDT 2005


Dear all,

I am writing a long string (several MByte) to a file,
with   writeFile fname ( render d )
where d :: Text.PrettyPrint.HughesPJ.Doc

I wonder what happens internally
(when compiled with ghc -O, if that matters)
Will the string be in memory completely
before it is actually written?

My  d  is in fact  vcat xs, for a list  xs
that is generated item by item.

Is there a way to get more efficient behaviour
without too much rewriting the program?
-- 
-- Johannes Waldmann -- Tel/Fax (0341) 3076 6479/80 --
---- http://www.imn.htwk-leipzig.de/~waldmann/ -------



More information about the Haskell mailing list