Good point. This brings us back to Russell's original suggestion of swap and swap' to cover both cases. That module has all of ~4 methods in it right now. -- I'm evaluating that lazily -- so its not exactly like adding both will break the complexity budget of a self-contained module designed to deal with tuples. ;)<br>
<br><div>-Edward Kmett</div><div><br><div class="gmail_quote">On Thu, Jun 18, 2009 at 1:27 AM, Jonathan Cast <span dir="ltr"><<a href="mailto:jonathanccast@fastmail.fm">jonathanccast@fastmail.fm</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On Thu, 2009-06-18 at 01:24 -0400, Edward Kmett wrote:<br>
> If we look at swap from the standpoint of the laws/RULES it should<br>
> support, viewing Hask over (,) as a symmetric monoidal category you<br>
> get something like:<br>
><br>
><br>
> {-# RULES<br>
> "swap . swap = id" forall x. swap (swap x) = x<br>
> "fst . swap = snd" forall x. fst (swap x) = snd x<br>
> "snd . swap = fst" forall x. snd (swap x) = fst x<br>
> #-}<br>
><br>
><br>
> That seems to argue for the lazy definition being the default to avoid<br>
> the strict pattern match in swap breaking the latter very pleasing<br>
> equalities.<br>
<br>
</div>Lazy swap fails the swap . swap rule:<br>
<br>
swap (swap undefined)<br>
= swap (snd undefined, fst undefined)<br>
= swap (undefined, undefined)<br>
= (undefined, undefined)<br>
<br>
which is distinct from undefined because Haskell tuples are lifted.<br>
<br>
jcc<br>
<br>
<br>
</blockquote></div><br></div>