Adding swap to Data.Tuple

Edward Kmett ekmett at gmail.com
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
like:
{-# 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 theorem.ca> 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                                      <http://r6.ca/>
> ``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 haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/libraries/attachments/20090618/7b46bdda/attachment-0001.html


More information about the Libraries mailing list