@@ -6,9 +6,11 @@ import Control.Monad.Eff (Eff)
66import Control.Monad.Eff.Console (CONSOLE , log )
77
88import Data.Foldable (foldMap , foldl )
9- import Data.List (List (Nil, Cons ), (..), length , range , foldM , unzip , zip , zipWithA , zipWith , intersectBy , intersect , (\\), deleteBy , delete , unionBy , union , nubBy , nub , groupBy , group' , group , span , dropWhile , drop , takeWhile , take , sortBy , sort , catMaybes , mapMaybe , filterM , filter , concat , concatMap , reverse , alterAt , modifyAt , updateAt , deleteAt , insertAt , findLastIndex , findIndex , elemLastIndex , elemIndex , (!!), uncons , init , tail , last , head , insertBy , insert , snoc , null , singleton , fromFoldable , transpose , mapWithIndex , (:))
9+ import Data.List (List (.. ), (..), length , range , foldM , unzip , zip , zipWithA , zipWith , intersectBy , intersect , (\\), deleteBy , delete , unionBy , union , nubBy , nub , groupBy , group' , group , span , dropWhile , drop , takeWhile , take , sortBy , sort , catMaybes , mapMaybe , filterM , filter , concat , concatMap , reverse , alterAt , modifyAt , updateAt , deleteAt , insertAt , findLastIndex , findIndex , elemLastIndex , elemIndex , (!!), uncons , init , tail , last , head , insertBy , insert , snoc , null , singleton , fromFoldable , transpose , mapWithIndex , (:))
1010import Data.Maybe (Maybe (..), isNothing , fromJust )
11- import Data.Monoid.Additive (Additive (Additive))
11+ import Data.Monoid.Additive (Additive (..))
12+ import Data.NonEmpty ((:|))
13+ import Data.NonEmpty as NE
1214import Data.Tuple (Tuple (..))
1315import Data.Unfoldable (replicate , replicateA , unfoldr )
1416
@@ -232,13 +234,13 @@ testList = do
232234 assert $ spanResult.rest == l [4 , 5 , 6 , 7 ]
233235
234236 log " group should group consecutive equal elements into lists"
235- assert $ group (l [1 , 2 , 2 , 3 , 3 , 3 , 1 ]) == l [l [ 1 ], l [2 , 2 ], l [3 , 3 , 3 ], l [ 1 ] ]
237+ assert $ group (l [1 , 2 , 2 , 3 , 3 , 3 , 1 ]) == l [NE .singleton 1 , 2 :| l [2 ], 3 :| l [3 , 3 ], NE .singleton 1 ]
236238
237239 log " group' should sort then group consecutive equal elements into lists"
238- assert $ group' (l [1 , 2 , 2 , 3 , 3 , 3 , 1 ]) == l [l [1 , 1 ], l [2 , 2 ], l [3 , 3 , 3 ]]
240+ assert $ group' (l [1 , 2 , 2 , 3 , 3 , 3 , 1 ]) == l [1 :| l [1 ], 2 :| l [2 ], 3 :| l [3 , 3 ]]
239241
240242 log " groupBy should group consecutive equal elements into lists based on an equivalence relation"
241- assert $ groupBy (\x y -> odd x && odd y) (l [1 , 1 , 2 , 2 , 3 , 3 ]) == l [l [1 , 1 ], l [ 2 ], l [ 2 ], l [3 , 3 ]]
243+ assert $ groupBy (\x y -> odd x && odd y) (l [1 , 1 , 2 , 2 , 3 , 3 ]) == l [1 :| l [1 ], NE .singleton 2 , NE .singleton 2 , 3 :| l [3 ]]
242244
243245 log " nub should remove duplicate elements from the list, keeping the first occurence"
244246 assert $ nub (l [1 , 2 , 2 , 3 , 4 , 1 ]) == l [1 , 2 , 3 , 4 ]
0 commit comments