data Tree a = Empty | Node a [Tree a]
toList :: Tree a -> [a]
toList Empty = []
toList (Node x l) = [x] ++ concat (map toList l)
toList
is a natural transformation. It is also a morphism from Tree
to []
in the Category of \(\Hask\) endofunctors.