<br><span class="Apple-style-span" style="font-size: small;"><br></span><div class="gmail_quote"><span class="Apple-style-span" style="font-size: small;">On Wed, Mar 25, 2009 at 4:09 PM, Simon Marlow </span><span dir="ltr"><span class="Apple-style-span" style="font-size: small;">&lt;<a href="mailto:marlowsd@gmail.com">marlowsd@gmail.com</a>&gt;</span></span><span class="Apple-style-span" style="font-size: small;"> wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im"><span class="Apple-style-span" style="font-size: small;">But it only works out nicely because the ordering of the components of the pair returned by splitAt matches the ordering that the state monad expects (and I can never remember which way around they are in Control.Monad.State).</span></div>
</blockquote><div><span class="Apple-style-span" style="font-size: small;"><br></span></div><div><span class="Apple-style-span" style="font-size: small;">Now you mention this, I often had to write a little function</span></div>
<div><span class="Apple-style-span" style="font-size: small;"><br></span></div><div><span class="Apple-style-span" style="font-family: Arial; white-space: pre; "><span class="Apple-style-span" style="font-size: small;">swap :: (a,b) -&gt; (b,a)</span></span><span class="Apple-style-span" style="font-size: small;"><br>
</span></div><div><span class="Apple-style-span" style="white-space: pre;"><span class="Apple-style-span" style="font-size: small;"><br></span></span></div><div><span class="Apple-style-span" style="white-space: pre;"><span class="Apple-style-span" style="font-size: small;">It seems many other authors have done the same in their own modules. Maybe this should be part of the Prelude?</span></span></div>
<div><span class="Apple-style-span" style="font-size: small;"> <br></span></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im"><span class="Apple-style-span" style="font-size: small;"><br>
</span></div>
<br>
Try doing it with mapAccumL, which is arguably the right abstraction, but has the components the other way around.<br>
<br>
Cheers,<br><font color="#888888">
        Simon</font><div><div></div><div class="h5"><br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br>