@@ -12,9 +12,8 @@ import Data.Function (on)
1212import Data.Functor.Compose
1313import Data.Functor.Identity (Identity (.. ))
1414import qualified Data.List as List
15- import qualified Data.List.NonEmpty as NE
1615import Data.Maybe (catMaybes , mapMaybe )
17- import Data.Ord (Down (.. ), comparing )
16+ import Data.Ord (Down (.. ))
1817import Test.ChasingBottoms.IsBottom
1918import Test.Tasty (TestTree , defaultMain , testGroup )
2019import Test.Tasty.QuickCheck (testProperty )
@@ -39,7 +38,7 @@ import qualified Data.IntMap.Merge.Lazy as LMerge
3938import Data.Containers.ListUtils
4039
4140import Utils.MergeFunc (WhenMatchedFunc (.. ), WhenMissingFunc (.. ))
42- import Utils.NubSorted (NubSortedOnFst (.. ))
41+ import Utils.QuickCheck (NubSortedOnFst ( .. ), SortedOnFst (.. ))
4342import Utils.Strictness
4443 (Bot (.. ), Func , Func2 , Func3 , applyFunc , applyFunc2 , applyFunc3 )
4544
@@ -162,100 +161,102 @@ prop_lazyFromListUpsert fun kvs = isNotBottomProp (L.fromListUpsert f kvs')
162161 f = coerce (applyFunc2 fun) :: A -> Maybe B -> B
163162 kvs' = coerce kvs :: [(Key , A )]
164163
165- prop_strictFromAscList :: [( Key , Bot A )] -> Property
164+ prop_strictFromAscList :: SortedOnFst Key ( Bot A ) -> Property
166165prop_strictFromAscList kvs =
167166 isBottom (M. fromAscList kvs') === isBottom (M. fromList kvs')
168167 where
169- kvs' = List. sortBy (comparing fst ) ( coerce kvs) :: [(Key , A )]
168+ kvs' = coerce kvs :: [(Key , A )]
170169
171- prop_lazyFromAscList :: [( Key , Bot A )] -> Property
170+ prop_lazyFromAscList :: SortedOnFst Key ( Bot A ) -> Property
172171prop_lazyFromAscList kvs = isNotBottomProp (L. fromAscList kvs')
173172 where
174- kvs' = List. sortBy (comparing fst ) ( coerce kvs) :: [(Key , A )]
173+ kvs' = coerce kvs :: [(Key , A )]
175174
176- prop_strictFromAscListWith :: Func2 A A (Bot A ) -> [(Key , Bot A )] -> Property
175+ prop_strictFromAscListWith
176+ :: Func2 A A (Bot A ) -> SortedOnFst Key (Bot A ) -> Property
177177prop_strictFromAscListWith fun kvs =
178178 isBottom (M. fromAscListWith f kvs') === isBottom (M. fromListWith f kvs')
179179 where
180180 f = coerce (applyFunc2 fun)
181- kvs' = List. sortBy (comparing fst ) ( coerce kvs) :: [(Key , A )]
181+ kvs' = coerce kvs :: [(Key , A )]
182182
183- prop_lazyFromAscListWith :: Func2 A A (Bot A ) -> [(Key , Bot A )] -> Property
183+ prop_lazyFromAscListWith
184+ :: Func2 A A (Bot A ) -> SortedOnFst Key (Bot A ) -> Property
184185prop_lazyFromAscListWith fun kvs = isNotBottomProp (L. fromAscListWith f kvs')
185186 where
186187 f = coerce (applyFunc2 fun)
187- kvs' = List. sortBy (comparing fst ) ( coerce kvs) :: [(Key , A )]
188+ kvs' = coerce kvs :: [(Key , A )]
188189
189190prop_strictFromAscListWithKey
190- :: Func3 Key A A (Bot A ) -> [( Key , Bot A )] -> Property
191+ :: Func3 Key A A (Bot A ) -> SortedOnFst Key ( Bot A ) -> Property
191192prop_strictFromAscListWithKey fun kvs =
192193 isBottom (M. fromAscListWithKey f kvs') ===
193194 isBottom (M. fromListWithKey f kvs')
194195 where
195196 f = coerce (applyFunc3 fun)
196- kvs' = List. sortBy (comparing fst ) ( coerce kvs) :: [(Key , A )]
197+ kvs' = coerce kvs :: [(Key , A )]
197198
198199prop_lazyFromAscListWithKey
199- :: Func3 Key A A (Bot A ) -> [( Key , Bot A )] -> Property
200+ :: Func3 Key A A (Bot A ) -> SortedOnFst Key ( Bot A ) -> Property
200201prop_lazyFromAscListWithKey fun kvs =
201202 isNotBottomProp (L. fromAscListWithKey f kvs')
202203 where
203204 f = coerce (applyFunc3 fun)
204- kvs' = List. sortBy (comparing fst ) ( coerce kvs) :: [(Key , A )]
205+ kvs' = coerce kvs :: [(Key , A )]
205206
206207prop_strictFromAscListUpsert
207- :: Func2 A (Maybe B ) (Bot B ) -> [( Key , Bot A )] -> Property
208+ :: Func2 A (Maybe B ) (Bot B ) -> SortedOnFst Key ( Bot A ) -> Property
208209prop_strictFromAscListUpsert fun kvs =
209210 isBottom (M. fromAscListUpsert f kvs') === isBottom (M. fromListUpsert f kvs')
210211 where
211212 f = coerce (applyFunc2 fun) :: A -> Maybe B -> B
212- kvs' = List. sortBy (comparing fst ) ( coerce kvs) :: [(Key , A )]
213+ kvs' = coerce kvs :: [(Key , A )]
213214
214215prop_lazyFromAscListUpsert
215- :: Func2 A (Maybe B ) (Bot B ) -> [( Key , Bot A )] -> Property
216+ :: Func2 A (Maybe B ) (Bot B ) -> SortedOnFst Key ( Bot A ) -> Property
216217prop_lazyFromAscListUpsert fun kvs =
217218 isNotBottomProp (L. fromAscListUpsert f kvs')
218219 where
219220 f = coerce (applyFunc2 fun) :: A -> Maybe B -> B
220- kvs' = List. sortBy (comparing fst ) ( coerce kvs) :: [(Key , A )]
221+ kvs' = coerce kvs :: [(Key , A )]
221222
222- prop_strictFromDistinctAscList :: [( Key , Bot A )] -> Property
223+ prop_strictFromDistinctAscList :: NubSortedOnFst Key ( Bot A ) -> Property
223224prop_strictFromDistinctAscList kvs =
224225 isBottom (M. fromDistinctAscList kvs') === isBottom (M. fromList kvs')
225226 where
226- kvs' = uniqOn fst $ List. sortBy (comparing fst ) ( coerce kvs) :: [(Key , A )]
227+ kvs' = coerce kvs :: [(Key , A )]
227228
228- prop_lazyFromDistinctAscList :: [( Key , Bot A )] -> Property
229+ prop_lazyFromDistinctAscList :: NubSortedOnFst Key ( Bot A ) -> Property
229230prop_lazyFromDistinctAscList kvs = isNotBottomProp (L. fromDistinctAscList kvs')
230231 where
231- kvs' = uniqOn fst $ List. sortBy (comparing fst ) ( coerce kvs) :: [(Key , A )]
232+ kvs' = coerce kvs :: [(Key , A )]
232233
233- prop_strictFromDescList :: [( Key , Bot A )] -> Property
234+ prop_strictFromDescList :: SortedOnFst ( Down Key ) ( Bot A ) -> Property
234235prop_strictFromDescList kvs =
235236 isBottom (M. fromDescList kvs') === isBottom (M. fromList kvs')
236237 where
237- kvs' = List. sortBy (comparing ( Down . fst )) ( coerce kvs) :: [(Key , A )]
238+ kvs' = coerce kvs :: [(Key , A )]
238239
239- prop_lazyFromDescList :: [( Key , Bot A )] -> Property
240+ prop_lazyFromDescList :: SortedOnFst ( Down Key ) ( Bot A ) -> Property
240241prop_lazyFromDescList kvs = isNotBottomProp (L. fromDescList kvs')
241242 where
242- kvs' = List. sortBy (comparing ( Down . fst )) ( coerce kvs) :: [(Key , A )]
243+ kvs' = coerce kvs :: [(Key , A )]
243244
244245prop_strictFromDescListUpsert
245- :: Func2 A (Maybe B ) (Bot B ) -> [( Key , Bot A )] -> Property
246+ :: Func2 A (Maybe B ) (Bot B ) -> SortedOnFst ( Down Key ) ( Bot A ) -> Property
246247prop_strictFromDescListUpsert fun kvs =
247248 isBottom (M. fromDescListUpsert f kvs') === isBottom (M. fromListUpsert f kvs')
248249 where
249250 f = coerce (applyFunc2 fun) :: A -> Maybe B -> B
250- kvs' = List. sortBy (comparing ( Down . fst )) ( coerce kvs) :: [(Key , A )]
251+ kvs' = coerce kvs :: [(Key , A )]
251252
252253prop_lazyFromDescListUpsert
253- :: Func2 A (Maybe B ) (Bot B ) -> [( Key , Bot A )] -> Property
254+ :: Func2 A (Maybe B ) (Bot B ) -> SortedOnFst ( Down Key ) ( Bot A ) -> Property
254255prop_lazyFromDescListUpsert fun kvs =
255256 isNotBottomProp (L. fromDescListUpsert f kvs')
256257 where
257258 f = coerce (applyFunc2 fun) :: A -> Maybe B -> B
258- kvs' = List. sortBy (comparing ( Down . fst )) ( coerce kvs) :: [(Key , A )]
259+ kvs' = coerce kvs :: [(Key , A )]
259260
260261prop_strictInsert :: Key -> Bot A -> IntMap A -> Property
261262prop_strictInsert k (Bot x) m = isBottom (M. insert k x m) === isBottom x
@@ -1186,10 +1187,6 @@ const2 x _ _ = x
11861187const3 :: a -> b -> c -> d -> a
11871188const3 x _ _ _ = x
11881189
1189- -- | Keep the first of adjacent equal elements.
1190- uniqOn :: Eq b => (a -> b ) -> [a ] -> [a ]
1191- uniqOn f = map NE. head . NE. groupBy ((==) `on` f)
1192-
11931190{- -------------------------------------------------------------------
11941191 Merge stuff
11951192--------------------------------------------------------------------}
0 commit comments