Efficient serialization of recursive data structures in Haskell

I am currently working with some of the large Trie structures in Haskell that I create from a binary file. The process took some time, and I was curious if there was a general approach to fast (de) serializing recursive data structures. For large files and large Tries, using the Show and Read classes is (much) slower than creating attempts from scratch. Maybe I'm doing it wrong.

Trie has the form:

type Trie ea = T e [Trie ea] 

What are good approaches to serializing a recursive structure? Also, what are some good approaches to this problem in general?

+7
source share
2 answers

The link to the output of the binary instance in the documentation is broken, as indicated in the comments on the question. But the file only exists at a new slightly different URL: http://darcs.haskell.org/packages/binary/tools/derive/BinaryDerive.hs

I haven't used it yet, but I think it does what you want.

+1
source

A general-purpose solution may be the implementation of Foldable and Unfoldable (I hope that the last class exists).

+1
source

All Articles