Adding swap to Data.Tuple

Edward Kmett ekmett at
Thu Jun 18 01:24:11 EDT 2009

If we look at swap from the standpoint of the laws/RULES it should support,
viewing Hask over (,) as a symmetric monoidal category you get something
{-# RULES"swap . swap = id" forall x. swap (swap x) = x
"fst . swap = snd" forall x. fst (swap x) = snd x
"snd . swap = fst" forall x. snd (swap x) = fst x

That seems to argue for the lazy definition being the default to avoid the
strict pattern match in swap breaking the latter very pleasing equalities.

-Edward Kmett

On Wed, Jun 17, 2009 at 8:52 PM, <roconnor at> wrote:

> How about this: swap should be lazy because that is how H98 defines
> uncurry:
> uncurry          :: (a -> b -> c) -> ((a, b) -> c)
> uncurry f p      =  f (fst p) (snd p)
> --
> Russell O'Connor                                      <>
> ``All talk about `theft,''' the general counsel of the American Graphophone
> Company wrote, ``is the merest claptrap, for there exists no property in
> ideas musical, literary or artistic, except as defined by statute.''
> _______________________________________________
> Libraries mailing list
> Libraries at
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Libraries mailing list