
There's always this, for ALL types a :( So even where you would think that
the documentation can claim that a given Eq instance follows the law of
commutativity, it really cannot.
Prelude Control.Concurrent System.IO.Unsafe> do m <- newEmptyMVar ;putMVar m
1 ; print $ (unsafePerformIO (do v <- takeMVar m; putMVar m 2; return v)) ==
(unsafePerformIO (do v <- takeMVar m; putMVar m 1 ; return v)) ; print $
(unsafePerformIO (do v <- takeMVar m; putMVar m 1; return v)) ==
(unsafePerformIO (do v <- takeMVar m; putMVar m 2 ; return v))
False
True
---------- Původní zpráva ----------
Od: Jonas Almström Duregård
Dear all,
with respect to formal verification of Haskell code I was wondering whether (==) of the Eq class is intended to be commutative (for many classes such requirements are informally stated in their description, since Eq does not have such a statement, I'm asking here). Or are there any known cases where commutativity of (==) is violated (due to strictness issues)?
cheers
chris
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe (http://www.haskell.org/mailman/listinfo/haskell-cafe)
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe (http://www.haskell.org/mailman/listinfo/haskell-cafe)"