Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Efficient Serializing of Recursive Data Structures in Haskell

Tags:

haskell

I am currently working with some large Trie structures in Haskell that I build from a binary file. The process takes some time, and I was curious if there is a general-case approach to fast-ish (de)serialization of recursive data structures. For large files and large Tries, using the Show and Read classes is (much) slower than building the tries from scratch. Perhaps I'm doing it wrong.

The Trie is shaped like this:

type Trie e a = T e [Trie e a]

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

like image 807
thegravian Avatar asked Oct 31 '11 17:10

thegravian


1 Answers

The link for deriving an instance of binary in the documentation is broken as stated in the comments of the question. But the file exists just 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 this does what you want.

like image 127
Ericson2314 Avatar answered Sep 29 '22 20:09

Ericson2314