[Haskell-beginners] tree structure for resolving nested references

Renah Scarowsky renahs at suite-sol.com
Thu Jan 30 11:38:46 UTC 2014


Hi,

 

I'm doing some xml processing where elements can reference each other in one
particular way.

Such a reference is resolved by copying the content of the referenced
element to the content of the referencing element.

For example, <A ref="B">foo</A>, <B>bar</B> would resolve to
<A>bar</A><B>bar</B>.

 

The references can also be nested, for example:

<A ref="B">foo</A>, <B ref="C">bar</B><C>baz</C> would resolve to
<A>baz</A><B>baz</B><C>baz</C>.

 

I'm looking to collect all the elements with such references in some sort of
(tree?) container for efficient resolution.

The container should serve two purposes:

1)      I need to check whether there are any cyclic references (for
example, A references B which references C which references A) - which is
invalid.

2)      I need to traverse the tree upwards in order to copy the content
from one element to another - beginning with the "leaves" (elements with
non-nested references), working up the "branches" (elements with nested
references) to the "roots" (elements with references that are not referenced
by other elements). Obviously there can be many roots, as well as many
leaves that are roots themselves.

 

I'm not familiar with trees in Haskell at all.  Can anyone provide some
guidance on whether there are any existing containers that would be
appropriate for checking cyclic dependencies and for reverse traversal?

 

 

Thanks,

 

Renah Scarowsky

Suite Solutions

Create>Manage>Deploy

 <http://www.suite-sol.com/> http://www.suite-sol.com

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140130/e0a707df/attachment.html>


More information about the Beginners mailing list