@@ -138,7 +138,6 @@ main = defaultMain
138138 , testCase " minViewWithKey" test_minViewWithKey
139139 , testCase " maxViewWithKey" test_maxViewWithKey
140140 , testCase " valid" test_valid
141- , testProperty " unionWith3" prop_unionWith3
142141 , testProperty " valid" prop_valid
143142 , testProperty " insert to singleton" prop_singleton
144143 , testProperty " insert" prop_insert
@@ -214,7 +213,7 @@ main = defaultMain
214213 ]
215214
216215{- -------------------------------------------------------------------
217- Arbitrary, reasonably balanced trees
216+ Arbitrary trees
218217--------------------------------------------------------------------}
219218instance (Enum k ,Arbitrary a ) => Arbitrary (Map k a ) where
220219 arbitrary = sized (arbtree 0 maxkey)
@@ -240,15 +239,15 @@ instance (Enum k,Arbitrary a) => Arbitrary (Map k a) where
240239
241240-- A type with a peculiar Eq instance designed to make sure keys
242241-- come from where they're supposed to.
243- data OddEq a = OddEq Bool a deriving (Show )
244- getOddEq :: OddEq a -> (Bool , a )
245- getOddEq (OddEq b a ) = (b, a )
242+ data OddEq a = OddEq a Bool deriving (Show )
243+ getOddEq :: OddEq a -> (a , Bool )
244+ getOddEq (OddEq a b ) = (a, b )
246245instance Arbitrary a => Arbitrary (OddEq a ) where
247246 arbitrary = OddEq <$> arbitrary <*> arbitrary
248247instance Eq a => Eq (OddEq a ) where
249- OddEq _ x == OddEq _ y = x == y
248+ OddEq x _ == OddEq y _ = x == y
250249instance Ord a => Ord (OddEq a ) where
251- OddEq _ x `compare` OddEq _ y = x `compare` y
250+ OddEq x _ `compare` OddEq y _ = x `compare` y
252251
253252------------------------------------------------------------------------
254253
@@ -984,22 +983,6 @@ prop_unionWith t1 t2 = (union t1 t2 == unionWith (\_ y -> y) t2 t1)
984983prop_unionWith2 :: IMap -> IMap -> Bool
985984prop_unionWith2 t1 t2 = valid (unionWithKey (\ _ x y -> x+ y) t1 t2)
986985
987- prop_unionWith3 :: Fun (Int ,Int ) Int -> IMap -> IMap -> Property
988- prop_unionWith3 f t1 t2 = valid uw .&&. uwUndone === uwEasyUndone
989- where
990- t1' :: Map (OddEq Int ) Int
991- t1' = mapKeysMonotonic (OddEq False ) t1
992- t2' :: Map (OddEq Int ) Int
993- t2' = mapKeysMonotonic (OddEq True ) t2
994- uw :: Map (OddEq Int ) Int
995- uw = unionWith (apply2 f) t1' t2'
996- uwUndone :: [((Bool , Int ), Int )]
997- uwUndone = first getOddEq <$> toList uw
998- uwEasy :: Map (OddEq Int ) Int
999- uwEasy = List. foldl' (\ t (k1, v1) -> insertWith (apply2 f) k1 v1 t) t2' (toList t1')
1000- uwEasyUndone :: [((Bool , Int ), Int )]
1001- uwEasyUndone = first getOddEq <$> toList uwEasy
1002-
1003986prop_unionSum :: [(Int ,Int )] -> [(Int ,Int )] -> Bool
1004987prop_unionSum xs ys
1005988 = sum (elems (unionWith (+) (fromListWith (+) xs) (fromListWith (+) ys)))
0 commit comments