[Haskell-cafe] Mystery operator?

David Menendez dave at zednenem.com
Mon Nov 30 14:29:54 EST 2009


On Mon, Nov 30, 2009 at 2:01 PM, michael rice <nowgate at yahoo.com> wrote:
>
> Hi all,
>
> A lot of things posted here I wasn't aware of. My original example involved ~(x,y), so,
> returning to that context, how would these two simple cases vary:
>
> add2 :: (Int,Int) -> Int
> add2 (x,y) = x+y
>
> add2 :: (Int,Int) -> Int
> add2 ~(x,y) = x+y
>
> I guess what I'm looking for is the concept that would dictate choosing one over the other.

These particular two functions are identical, because (+) is strict for Ints.

But consider these two functions:

swap ~(x,y) = (y,x)
swap' (x,y) = (y,x)

swap is non-strict, and swap' is strict.

swap _|_ = (_|_, _|_)
swap' _|_ = _|_


--
Dave Menendez <dave at zednenem.com>
<http://www.eyrie.org/~zednenem/>


More information about the Haskell-Cafe mailing list