News for hackers. Stuff that matters.
Re:Learn you a Haskell: Zippers by eru on Thursday November 04, 2010 @07:17AM (#1868415)
I know how to get a zipper for a static graph by Tying the Knot (http://haskell.org/haskellwiki/Tying_the_Knot). But writing one where you can add and remove nodes and edges seems much harder.

You already know how a zipper for a tree looks like. And you have probably seen a functional queue. Generalizing from both of those, you can imagine how a zipper would work.

I can write down the types and all, even if I don't know of any implementation. But that's probably a topic for a blog post, or so.

Re:Learn you a Haskell: Zippers by copper on Thursday November 04, 2010 @08:42AM (#1868595)
I think I understand that, but without actually writing it out, it's going to be impossible to test.

The types I was talking about go as: type Context a b = (Adj b, Node, a, Adj b) type Adj b = [(b, Node)]

It definitely allows traversal, and adding nodes seems to be possible, too (judging from the api, of course, it ought to be :)

Re:Learn you a Haskell: Zippers by eru on Thursday November 04, 2010 @11:12AM (#1869205)
From the types you give, I can't see how it works. Would you please elaborate?