<div dir="ltr">Er... I may have mixed up preorder and depth-first -- I tend to do that. The point is, whatever it doesn't do, it should do.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 21, 2015 at 12:08 AM, Dan Burton <span dir="ltr"><<a href="mailto:danburton.email@gmail.com" target="_blank">danburton.email@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">+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.<div><br></div><div>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.</div><div><br></div><div><font face="monospace, monospace">depthFirst :: Applicative f => (a -> f b) -> Tree a -> f (Tree b)</font></div><div><font face="monospace, monospace">depthFirst = ...</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">preOrder :: Applicative f => (a -> f b) -> Tree a -> f (Tree b)</font></div><div><font face="monospace, monospace">preOrder = ...</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">postOrder :: Applicative f => (a -> f b) -> Tree a -> f (Tree b)</font></div><div><font face="monospace, monospace">postOrder = ...<br><br></font></div><div><div><font face="monospace, monospace">inOrder :: Applicative f => (a -> f b) -> Tree a -> f (Tree b)</font></div><div><font face="monospace, monospace">inOrder = traverse</font><br></div></div></div><div class="gmail_extra"><br clear="all"><div><div>-- Dan Burton</div></div>
<br><div class="gmail_quote"><span class="">On Mon, Apr 20, 2015 at 8:20 PM, David Feuer <span dir="ltr"><<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>></span> wrote:<br></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><div dir="ltr"><div>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.<span><font color="#888888"><br><br></font></span></div><span><font color="#888888">David Feuer<br></font></span></div>
<br></span>_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>