
22 Sep
2005
22 Sep
'05
3:55 p.m.
I'm porting an ML program to Haskell, but am having difficulty with particular data structure: a tree where each node has references to the children as well as the parent... data Tree a = TreeRoot { stuff :: a , children :: [Tree] } | TreeNode { stuff :: a , parent :: Tree , children :: [Tree] } But because of these bidirectional links, every time I add a node I must reconstructing the entire tree. There is also the add coding complexity of threading the tree through various functions to simulate state. What are my [monadic] options? -Tom