[Haskell-cafe] Saving a data structure to a file
Neil Mitchell
ndmitchell at gmail.com
Fri Apr 28 11:59:22 EDT 2006
Hi,
I have a program which needs to cache intermediate data structures to
a file (finite, non-cyclic, relatively simple, around ~100Kb when
shown). Is there any easy way to acheive this?
The current approach I am using is to add deriving Read, Show to all
the data structures, and then
writeFile "output.txt" (show x)
read =<< readFile "output.txt"
The problem is that this is too slow, and itsn't lazy. Is there any
way to do better than this? I can imagine something like
showBinary/readBinary which did this using binary files directly, but
is there anything that does this?
I'd like it to work with GHC and Hugs at least, and the less extra
code I have to write the better :)
Thanks
Neil
More information about the Haskell-Cafe
mailing list