[Haskell wikibook] Article ANN: Theseus and the zipper
dmhouse at gmail.com
Mon Feb 19 13:49:52 EST 2007
The following applies only to the first section, for now, which is all
On 19/02/07, apfelmus at quantentunnel.de <apfelmus at quantentunnel.de> wrote:
> Of course, comments, corrections and criticism are welcome!
I made a single correction and expanded on one quick point:
My comments, then:
1) Any reason you're not using the standard camelCase?
2) Any reason the maze datatypes take an extra parameter? For
simplicity, I'd have expected:
data Node = DeadEnd
| Passage Node
| Fork Node Node
And so on.
3) You could do with splitting the first section into various
subsections, it's a bit long and unwieldy as-is.
4) I'm not sure I like the typesetting of the conversation using lots
of <br>s, but I can't think of a better way of doing it off the top of
5) I don't really get this picture:
Is the red bit meant to be one long, straight arrow?
6) I don't think you spend enough time with the zipper concept. I
found when I read Huet's paper that zippers were one of those
brain-exploding concepts, perhaps because everything is stored
backwards. A few suggestions that would have helped me:
* We store the entirety of the labyrinth in any zipper; by zipping all
the way to the top so that the focus is at the entrance, the
sub-labyrinth is the whole labyrinth. The reason this is done is so
that we can backtrack and take an alternate path at any point.
* We definitely need to show a zipper for another datatype, perhaps
binary trees. I suggest with this one, we break the narrative and
explain step by step what each constructor means. Something like the
data BinTree a = Leaf | Node a (BinTree a) (BinTree a)
data BinThread a = Root | Left a (BinTree a) | Right (BinTree a) a
type BinZip a = (BinThread a, BinTree a)
Root = The focus is at the top of the tree.
L x t = We went left at a node where the value was x and the right subtree t.
R t x = We went right at a node where the value was x and the left subtree t.
Then give examples. The best way is probably to give an example
BinTree in a picture, pick one element out, display the zipper for
that element and explain what it means. This sound like a good plan?
As a way for the reader to confirm their knowledge, show them the
simple zipper for lists:
data List a = End | Cons a (List a)
data ListThread a = El a (List a)
type ListZip a = (ListThread a, List a)
Then set an exercise for the reader to explain to themselves how this
works. I'd set this lot just before the 'half a year later', so we can
return to the narrative as a nice ending.
I'm sure I'll think of more, but that's it for now.
-David House, dmhouse at gmail.com
More information about the Wikibook