<p dir="ltr">I just realized there *is* a way to implement traverseWithIndex reasonably efficiently with the current interface:</p>
<p dir="ltr">traverseWithIndex f = sequenceA . mapWithIndex f</p>
<p dir="ltr">I still think it's a good thing to add though.</p>
<div class="gmail_quote">On Jan 19, 2016 12:24 PM, "Milan Straka" <<a href="mailto:milan@strakovi.com">milan@strakovi.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi David and all,<br>
<br>
> -----Original message-----<br>
> From: David Feuer <<a href="mailto:david.feuer@gmail.com">david.feuer@gmail.com</a>><br>
> Sent: 19 Jan 2016, 11:55<br>
><br>
> Indexed traversals seem to be pretty popular these days, and sequences<br>
> should be able to support them efficiently. At present, the best<br>
> options are<br>
><br>
> 1. Thread a counter through. This doesn't work well for weird things<br>
> like lazy State.<br>
><br>
> 2. Use zipWith first to add indices, then traverse. This adds a<br>
> smaller, but still asymptotic, penalty to the same sorts of unusual<br>
> functors, and also adds constant-factor overhead to strict ones that<br>
> the counter threading wouldn't.<br>
><br>
> I propose the following, modified mechanically from mapWithIndex. It<br>
> should be about as efficient as possible in all cases.<br>
<br>
+1 from me.<br>
<br>
BTW, we have traverseWithKey in Map and IntMap, and traverseWithIndex<br>
seems a bit analogous for (indexable) Sequences, where an index can play<br>
a role of a key.<br>
<br>
Cheers,<br>
Milan<br>
</blockquote></div>