[Haskell-cafe] Haskell symbol ~

Neil Mitchell ndmitchell at gmail.com
Wed Aug 27 14:56:56 EDT 2008


Hi

> At the same place, I found that example,
> but wasn't wise enough to figure out
> what it does:
>
> (f *** g) ~(x,y) = (f x, g y)
>
> Can you help me understand it?

It means exactly the same as:

(f *** g) xy = (f (fst xy), g (snd xy))

i.e. if you call (f *** g) undefined, you will get (f undefined, g
undefined). If the pattern was strict (i.e. no ~) you would get
undefined.

Please update the keyword wiki so it makes sense to you, after you
have got your head round it.

Thanks

Neil


More information about the Haskell-Cafe mailing list