
On Wed, Mar 16, 2011 at 03:03:20PM +0100, Yves Parès wrote:
Concerning this exercise, would it be simply possible to take the most of lazy evaluation and build a graph?
A node would be: Node a = Node { data :: a, parents :: [Node a], children :: [Node a] }
Then, whichever node you are on, you can still directly find its predecessors, i.e. your way back in the labyrinth. I find it more simple than a zipper (of course, now you cannot serialize it, due to the cross-references).
This kind of "knot-tying" approach is nice for static graphs. However, update is quite complicated and definitely not constant time (you essentially have to rebuild the entire graph). A zipper allows O(1) updates to the current location. -Brent