We have a tree data type like this:
data Tree a = Tree a [Tree a] deriving Show
And we wish to write a function that assigns a number to each node of the tree, from an incrementing counter:
tag :: Tree a -> Tree (a, Int)
The long way
First we'll do it the long way around, since it illust...