File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,18 @@ import Control.Sequential.STM (STM)
4141-- but it may be replaced by a more efficient implementation in the future
4242-- (the interface will remain the same, however).
4343--
44- newtype TArray i e = TArray (Array i (TVar e )) deriving (Eq , Typeable )
44+ newtype TArray i e = TArray (Array i (TVar e )) deriving (Typeable )
45+
46+ -- There are no provisions for moving/copying TVars between TArrays.
47+ -- Therefore, two TArrays are equal if and only if they are actually
48+ -- the same array in memory. We have no safe operations for checking that
49+ -- directly (though in practice we could use `unsafeCoerce#` with
50+ -- `sameMutableArray#`). So instead we take a quick look at the array
51+ -- sizes and then decide based on the first TVar of each.
52+ instance Eq (TArray i e ) where
53+ TArray t1 == TArray t2
54+ = numElements t1 == numElements t2
55+ && (numElements t1 == 0 || unsafeAt t1 0 == unsafeAt t2 0 )
4556
4657instance MArray TArray e STM where
4758 getBounds (TArray a) = return (bounds a)
You can’t perform that action at this time.
0 commit comments