[Haskell-cafe] commutativity

Roel van Dijk vandijk.roel at gmail.com
Mon Nov 1 06:33:45 EDT 2010


Yes, that would prevent the shadowing. But now you are ignoring the
argument op1. Choosing a name that is more different from 'op' might
be helpful. You can even invent your own operator as an argument to
your commutative function:

  commutative (⊕) = \a b -> (a ⊕ b) == (b ⊕ a)

On Mon, Nov 1, 2010 at 11:15 AM, Patrick Browne <patrick.browne at dit.ie> wrote:
> Does the following avoid the shadowing?
>
> infixl 5 `op`
> op :: Int -> Int -> Int
> x `op` y  = (x + y)
> commutative op1 = \a b ->  (a `op` b) == (b `op` a)


More information about the Haskell-Cafe mailing list