[Haskell-cafe] commutativity

Patrick Browne patrick.browne at dit.ie
Mon Nov 1 06:15:33 EDT 2010

On 31/10/2010 16:55, Brent Yorgey wrote:
>> Note that the first parameter to commutative shadows the previous
>> definition of com, I don't know if that's what you intended.

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)

This message has been scanned for content and viruses by the DIT Information Services E-Mail Scanning Service, and is believed to be clean. http://www.dit.ie

More information about the Haskell-Cafe mailing list