+1 I don't see why not. Pre-order and post-order are also pretty textbook traversals. I don't imagine they'll be used very heavily, but they're certainly good for learning purposes.

Perhaps instead of newtypes for each of these, we can just provide the corresponding "traverse" function. These types unsurprisingly correspond to lens's Traversal (Tree a) (Tree b) a b.

depthFirst :: Applicative f => (a -> f b) -> Tree a -> f (Tree b)
depthFirst = ...

preOrder :: Applicative f => (a -> f b) -> Tree a -> f (Tree b)
preOrder = ...

postOrder :: Applicative f => (a -> f b) -> Tree a -> f (Tree b)
postOrder = ...

inOrder :: Applicative f => (a -> f b) -> Tree a -> f (Tree b)
inOrder = traverse

-- Dan Burton

On Mon, Apr 20, 2015 at 8:20 PM, David Feuer <david.feuer@gmail.com> wrote:
Data.Tree makes Tree into a Traversable in only one way: depth-first. It seems to me that we should have a newtype to traverse in breadth-first order.

David Feuer

_______________________________________________
Libraries mailing list
Libraries@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries