11module Test.Data.List (testList ) where
22
3- import Prelude
3+ import Prelude ( Unit , (*), zero , (/=), mod , (+), (==), ($), bind , pure , void , show , (<), (&&), compare , flip , const , (<<<), map , negate )
44import Control.Monad.Eff (Eff ())
55import Control.Monad.Eff.Console (CONSOLE (), log )
6- import Data.Foldable
7- import Data.Monoid.Additive
8- import Data.List
6+ import Data.Foldable ( foldMap , foldl )
7+ import Data.Monoid.Additive ( Additive (Additive))
8+ 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 , replicateM , replicate , singleton , fromFoldable , transpose , (:))
99import Data.Maybe (Maybe (..), isNothing )
1010import Data.Maybe.Unsafe (fromJust )
1111import Data.Tuple (Tuple (..))
@@ -120,12 +120,12 @@ testList = do
120120 assert $ elemLastIndex 4 (l [1 , 2 , 1 ]) == Nothing
121121
122122 log " findIndex should return the index of an item that a predicate returns true for in an list"
123- assert $ findIndex (/= 1 ) (l [1 , 2 , 1 ]) == Just 1
124- assert $ findIndex (== 3 ) (l [1 , 2 , 1 ]) == Nothing
123+ assert $ findIndex (_ /= 1 ) (l [1 , 2 , 1 ]) == Just 1
124+ assert $ findIndex (_ == 3 ) (l [1 , 2 , 1 ]) == Nothing
125125
126126 log " findLastIndex should return the last index of an item in an list"
127- assert $ findLastIndex (/= 1 ) (l [2 , 1 , 2 ]) == Just 2
128- assert $ findLastIndex (== 3 ) (l [2 , 1 , 2 ]) == Nothing
127+ assert $ findLastIndex (_ /= 1 ) (l [2 , 1 , 2 ]) == Just 2
128+ assert $ findLastIndex (_ == 3 ) (l [2 , 1 , 2 ]) == Nothing
129129
130130 log " insertAt should add an item at the specified index"
131131 assert $ (insertAt 0 1 (l [2 , 3 ])) == Just (l [1 , 2 , 3 ])
@@ -150,22 +150,22 @@ testList = do
150150 assert $ (updateAt 1 9 nil) == Nothing
151151
152152 log " modifyAt should update an item at the specified index"
153- assert $ (modifyAt 0 (+ 1 ) (l [1 , 2 , 3 ])) == Just (l [2 , 2 , 3 ])
154- assert $ (modifyAt 1 (+ 1 ) (l [1 , 2 , 3 ])) == Just (l [1 , 3 , 3 ])
153+ assert $ (modifyAt 0 (_ + 1 ) (l [1 , 2 , 3 ])) == Just (l [2 , 2 , 3 ])
154+ assert $ (modifyAt 1 (_ + 1 ) (l [1 , 2 , 3 ])) == Just (l [1 , 3 , 3 ])
155155
156156 log " modifyAt should return Nothing if the index is out of range"
157- assert $ (modifyAt 1 (+ 1 ) nil) == Nothing
157+ assert $ (modifyAt 1 (_ + 1 ) nil) == Nothing
158158
159159 log " alterAt should update an item at the specified index when the function returns Just"
160- assert $ (alterAt 0 (Just <<< (+ 1 )) (l [1 , 2 , 3 ])) == Just (l [2 , 2 , 3 ])
161- assert $ (alterAt 1 (Just <<< (+ 1 )) (l [1 , 2 , 3 ])) == Just (l [1 , 3 , 3 ])
160+ assert $ (alterAt 0 (Just <<< (_ + 1 )) (l [1 , 2 , 3 ])) == Just (l [2 , 2 , 3 ])
161+ assert $ (alterAt 1 (Just <<< (_ + 1 )) (l [1 , 2 , 3 ])) == Just (l [1 , 3 , 3 ])
162162
163163 log " alterAt should drop an item at the specified index when the function returns Nothing"
164164 assert $ (alterAt 0 (const Nothing ) (l [1 , 2 , 3 ])) == Just (l [2 , 3 ])
165165 assert $ (alterAt 1 (const Nothing ) (l [1 , 2 , 3 ])) == Just (l [1 , 3 ])
166166
167167 log " alterAt should return Nothing if the index is out of range"
168- assert $ (alterAt 1 (Just <<< (+ 1 )) nil) == Nothing
168+ assert $ (alterAt 1 (Just <<< (_ + 1 )) nil) == Nothing
169169
170170 log " reverse should reverse the order of items in an list"
171171 assert $ (reverse (l [1 , 2 , 3 ])) == l [3 , 2 , 1 ]
@@ -204,22 +204,22 @@ testList = do
204204 assert $ (take 1 nil) == nil
205205
206206 log " takeWhile should keep all values that match a predicate from the front of an list"
207- assert $ (takeWhile (/= 2 ) (l [1 , 2 , 3 ])) == l [1 ]
208- assert $ (takeWhile (/= 3 ) (l [1 , 2 , 3 ])) == l [1 , 2 ]
209- assert $ (takeWhile (/= 1 ) nil) == nil
207+ assert $ (takeWhile (_ /= 2 ) (l [1 , 2 , 3 ])) == l [1 ]
208+ assert $ (takeWhile (_ /= 3 ) (l [1 , 2 , 3 ])) == l [1 , 2 ]
209+ assert $ (takeWhile (_ /= 1 ) nil) == nil
210210
211211 log " drop should remove the specified number of items from the front of an list"
212212 assert $ (drop 1 (l [1 , 2 , 3 ])) == l [2 , 3 ]
213213 assert $ (drop 2 (l [1 , 2 , 3 ])) == l [3 ]
214214 assert $ (drop 1 nil) == nil
215215
216216 log " dropWhile should remove all values that match a predicate from the front of an list"
217- assert $ (dropWhile (/= 1 ) (l [1 , 2 , 3 ])) == l [1 , 2 , 3 ]
218- assert $ (dropWhile (/= 2 ) (l [1 , 2 , 3 ])) == l [2 , 3 ]
219- assert $ (dropWhile (/= 1 ) nil) == nil
217+ assert $ (dropWhile (_ /= 1 ) (l [1 , 2 , 3 ])) == l [1 , 2 , 3 ]
218+ assert $ (dropWhile (_ /= 2 ) (l [1 , 2 , 3 ])) == l [2 , 3 ]
219+ assert $ (dropWhile (_ /= 1 ) nil) == nil
220220
221221 log " span should split an list in two based on a predicate"
222- let spanResult = span (< 4 ) (l [1 , 2 , 3 , 4 , 5 , 6 , 7 ])
222+ let spanResult = span (_ < 4 ) (l [1 , 2 , 3 , 4 , 5 , 6 , 7 ])
223223 assert $ spanResult.init == l [1 , 2 , 3 ]
224224 assert $ spanResult.rest == l [4 , 5 , 6 , 7 ]
225225
0 commit comments