[Haskell-cafe] Re: Re: hxt memory useage

Uwe Schmidt uwe at fh-wedel.de
Tue Jan 29 03:44:16 EST 2008

Rene de Visser wrote:

> If I remember correctly, the data type of the tree in HXT is something like
> data Tree = Tree NodeData [Tree]
> which means that already processed parts of the tree can't be garbage 
> collected because the parent node is holding onto them.

This statement only holds, if you still need the root node
after processing.

When the tree is processed top down,
the root and all trees to the left of the currently
processed tree can be garbage collected.
This is precisely the type of computation needed
when e.g. working with picklers to convert XML
into native Haskell data structures.

BTW: I've taken the tagsoup lib and wrote
a small parser to build a tree out of the stream
of tags. It's about a 100 lines of code.
This DOM parser does not need to read until
the closing tag to build an element node,
so it should be as lasy as possible.
A first version for HTML
already runs on my box,
but it stil needs a bit of testing


More information about the Haskell-Cafe mailing list