@@ -4,7 +4,7 @@ import Prelude
44
55import Data.Foldable (foldMap , foldl )
66import Data.FoldableWithIndex (foldMapWithIndex , foldlWithIndex , foldrWithIndex )
7- import Data.List (List (..), (..), stripPrefix , Pattern (..), length , range , foldM , unzip , zip , zipWithA , zipWith , intersectBy , intersect , (\\), deleteBy , delete , unionBy , union , nubBy , nub , groupBy , group' , group , partition , span , dropWhile , drop , dropEnd , takeWhile , take , takeEnd , sortBy , sort , catMaybes , mapMaybe , filterM , filter , concat , concatMap , reverse , alterAt , modifyAt , updateAt , deleteAt , insertAt , findLastIndex , findIndex , elemLastIndex , elemIndex , (!!), uncons , unsnoc , init , tail , last , head , insertBy , insert , snoc , null , singleton , fromFoldable , transpose , mapWithIndex , (:))
7+ import Data.List (List (..), (..), stripPrefix , Pattern (..), length , range , foldM , unzip , zip , zipWithA , zipWith , intersectBy , intersect , (\\), deleteBy , delete , unionBy , union , nubBy , nub , group , groupAll , groupBy , groupAllBy , partition , span , dropWhile , drop , dropEnd , takeWhile , take , takeEnd , sortBy , sort , catMaybes , mapMaybe , filterM , filter , concat , concatMap , reverse , alterAt , modifyAt , updateAt , deleteAt , insertAt , findLastIndex , findIndex , elemLastIndex , elemIndex , (!!), uncons , unsnoc , init , tail , last , head , insertBy , insert , snoc , null , singleton , fromFoldable , transpose , mapWithIndex , (:))
88import Data.List.NonEmpty as NEL
99import Data.Maybe (Maybe (..), isNothing , fromJust )
1010import Data.Monoid.Additive (Additive (..))
@@ -267,12 +267,15 @@ testList = do
267267 log " group should group consecutive equal elements into lists"
268268 assert $ group (l [1 , 2 , 2 , 3 , 3 , 3 , 1 ]) == l [NEL .singleton 1 , NEL.NonEmptyList (2 :| l [2 ]), NEL.NonEmptyList (3 :| l [3 , 3 ]), NEL .singleton 1 ]
269269
270- log " group' should sort then group consecutive equal elements into lists"
271- assert $ group' (l [1 , 2 , 2 , 3 , 3 , 3 , 1 ]) == l [NEL.NonEmptyList (1 :| l [1 ]), NEL.NonEmptyList (2 :| l [2 ]), NEL.NonEmptyList (3 :| l [3 , 3 ])]
270+ log " groupAll should group equal elements into lists"
271+ assert $ groupAll (l [1 , 2 , 2 , 3 , 3 , 3 , 1 ]) == l [NEL.NonEmptyList (1 :| l [1 ]), NEL.NonEmptyList (2 :| l [2 ]), NEL.NonEmptyList (3 :| l [3 , 3 ])]
272272
273273 log " groupBy should group consecutive equal elements into lists based on an equivalence relation"
274274 assert $ groupBy (\x y -> odd x && odd y) (l [1 , 1 , 2 , 2 , 3 , 3 ]) == l [NEL.NonEmptyList (1 :| l [1 ]), NEL .singleton 2 , NEL .singleton 2 , NEL.NonEmptyList (3 :| l [3 ])]
275275
276+ log " groupAllBy should group equal elements into lists based on an equivalence relation"
277+ assert $ groupAllBy (\x y -> odd x && odd y) (l [1 , 3 , 2 , 4 , 3 , 3 ]) == l [NEL .singleton 1 , NEL .singleton 2 , NEL.NonEmptyList (3 :| l [3 , 3 ]), NEL .singleton 4 ]
278+
276279 log " partition should separate a list into a tuple of lists that do and do not satisfy a predicate"
277280 let partitioned = partition (_ > 2 ) (l [1 , 5 , 3 , 2 , 4 ])
278281 assert $ partitioned.yes == l [5 , 3 , 4 ]
0 commit comments