@@ -30,10 +30,10 @@ instance Hashable Key where
3030------------------------------------------------------------------------
3131-- ** Instances
3232
33- pEq :: [Key ] -> [Key ] -> Bool
33+ pEq :: [Key ] -> [Key ] -> Property
3434pEq xs = (Set. fromList xs == ) `eq` (S. fromList xs == )
3535
36- pNeq :: [Key ] -> [Key ] -> Bool
36+ pNeq :: [Key ] -> [Key ] -> Property
3737pNeq xs = (Set. fromList xs /= ) `eq` (S. fromList xs /= )
3838
3939-- We cannot compare to `Data.Map` as ordering is different.
@@ -78,7 +78,7 @@ pOrdEq xs ys = case (compare x y, x == y) of
7878pReadShow :: [Key ] -> Bool
7979pReadShow xs = Set. fromList xs == read (show (Set. fromList xs))
8080
81- pFoldable :: [Int ] -> Bool
81+ pFoldable :: [Int ] -> Property
8282pFoldable = (List. sort . Foldable. foldr (:) [] ) `eq`
8383 (List. sort . Foldable. foldr (:) [] )
8484
@@ -105,42 +105,42 @@ pHashable xs is salt =
105105------------------------------------------------------------------------
106106-- ** Basic interface
107107
108- pSize :: [Key ] -> Bool
108+ pSize :: [Key ] -> Property
109109pSize = Set. size `eq` S. size
110110
111- pMember :: Key -> [Key ] -> Bool
111+ pMember :: Key -> [Key ] -> Property
112112pMember k = Set. member k `eq` S. member k
113113
114- pInsert :: Key -> [Key ] -> Bool
114+ pInsert :: Key -> [Key ] -> Property
115115pInsert a = Set. insert a `eq_` S. insert a
116116
117- pDelete :: Key -> [Key ] -> Bool
117+ pDelete :: Key -> [Key ] -> Property
118118pDelete a = Set. delete a `eq_` S. delete a
119119
120120------------------------------------------------------------------------
121121-- ** Combine
122122
123- pUnion :: [Key ] -> [Key ] -> Bool
123+ pUnion :: [Key ] -> [Key ] -> Property
124124pUnion xs ys = Set. union (Set. fromList xs) `eq_`
125125 S. union (S. fromList xs) $ ys
126126
127127------------------------------------------------------------------------
128128-- ** Transformations
129129
130- pMap :: [Key ] -> Bool
130+ pMap :: [Key ] -> Property
131131pMap = Set. map (+ 1 ) `eq_` S. map (+ 1 )
132132
133133------------------------------------------------------------------------
134134-- ** Folds
135135
136- pFoldr :: [Int ] -> Bool
136+ pFoldr :: [Int ] -> Property
137137pFoldr = (List. sort . foldrSet (:) [] ) `eq`
138138 (List. sort . S. foldr (:) [] )
139139
140140foldrSet :: (a -> b -> b ) -> b -> Set. Set a -> b
141141foldrSet = Set. foldr
142142
143- pFoldl' :: Int -> [Int ] -> Bool
143+ pFoldl' :: Int -> [Int ] -> Property
144144pFoldl' z0 = foldl'Set (+) z0 `eq` S. foldl' (+) z0
145145
146146foldl'Set :: (a -> b -> a ) -> a -> Set. Set b -> a
@@ -149,13 +149,13 @@ foldl'Set = Set.foldl'
149149------------------------------------------------------------------------
150150-- ** Filter
151151
152- pFilter :: [Key ] -> Bool
152+ pFilter :: [Key ] -> Property
153153pFilter = Set. filter odd `eq_` S. filter odd
154154
155155------------------------------------------------------------------------
156156-- ** Conversions
157157
158- pToList :: [Key ] -> Bool
158+ pToList :: [Key ] -> Property
159159pToList = Set. toAscList `eq` toAscList
160160
161161------------------------------------------------------------------------
@@ -211,22 +211,21 @@ type Model a = Set.Set a
211211
212212-- | Check that a function operating on a 'HashMap' is equivalent to
213213-- one operating on a 'Model'.
214- eq :: (Eq a , Hashable a , Ord a , Eq b )
214+ eq :: (Eq a , Hashable a , Ord a , Show a , Eq b , Show b )
215215 => (Model a -> b ) -- ^ Function that modifies a 'Model' in the same
216216 -- way
217217 -> (S. HashSet a -> b ) -- ^ Function that modified a 'HashSet'
218218 -> [a ] -- ^ Initial content of the 'HashSet' and 'Model'
219- -> Bool -- ^ True if the functions are equivalent
220- eq f g xs = g ( S . fromList xs) == f ( Set . fromList xs)
219+ -> Property
220+ eq f g xs = f ( Set . fromList xs) === g ( S . fromList xs)
221221
222- eq_ :: (Eq a , Hashable a , Ord a )
222+ eq_ :: (Eq a , Hashable a , Ord a , Show a )
223223 => (Model a -> Model a ) -- ^ Function that modifies a 'Model'
224224 -> (S. HashSet a -> S. HashSet a ) -- ^ Function that modified a
225225 -- 'HashSet' in the same way
226226 -> [a ] -- ^ Initial content of the 'HashSet'
227227 -- and 'Model'
228- -> Bool -- ^ True if the functions are
229- -- equivalent
228+ -> Property
230229eq_ f g = (Set. toAscList . f) `eq` (toAscList . g)
231230
232231------------------------------------------------------------------------
0 commit comments