@@ -5,10 +5,11 @@ import Prelude
55import Control.Monad.Eff (Eff )
66import Control.Monad.Eff.Console (log , CONSOLE )
77
8- import Data.Array (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 , (:), length , null , replicate , replicateM , singleton , fromFoldable )
8+ import Data.Array (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 , (:), length , null , singleton , fromFoldable )
99import Data.Foldable (for_ , foldMapDefaultR , class Foldable , all )
1010import Data.Maybe (Maybe (..), isNothing , fromJust )
1111import Data.Tuple (Tuple (..))
12+ import Data.Unfoldable (replicate , replicateA )
1213
1314import Partial.Unsafe (unsafePartial )
1415
@@ -32,15 +33,15 @@ testArray = do
3233 assert $ replicate 0 " foo" == []
3334 assert $ replicate (-1 ) " foo" == []
3435
35- log " replicateM should perform the monadic action the correct number of times"
36- assert $ replicateM 3 (Just 1 ) == Just [1 , 1 , 1 ]
37- assert $ replicateM 1 (Just 1 ) == Just [1 ]
38- assert $ replicateM 0 (Just 1 ) == Just []
39- assert $ replicateM (-1 ) (Just 1 ) == Just []
36+ log " replicateA should perform the monadic action the correct number of times"
37+ assert $ replicateA 3 (Just 1 ) == Just [1 , 1 , 1 ]
38+ assert $ replicateA 1 (Just 1 ) == Just [1 ]
39+ assert $ replicateA 0 (Just 1 ) == Just []
40+ assert $ replicateA (-1 ) (Just 1 ) == Just []
4041
41- log " replicateM should be stack safe"
42+ log " replicateA should be stack safe"
4243 for_ [1 , 1000 , 2000 , 20000 , 50000 ] \n -> do
43- assert $ replicateM n (Just unit) == Just (replicate n unit)
44+ assert $ replicateA n (Just unit) == Just (replicate n unit :: Array Unit )
4445
4546 -- some
4647 -- many
@@ -165,15 +166,15 @@ testArray = do
165166 assert $ (modifyAt 1 (_ + 1 ) nil) == Nothing
166167
167168 log " alterAt should update an item at the specified index when the function returns Just"
168- assert $ (alterAt 0 (Just <<< (+ 1 )) [1 , 2 , 3 ]) == Just [2 , 2 , 3 ]
169- assert $ (alterAt 1 (Just <<< (+ 1 )) [1 , 2 , 3 ]) == Just [1 , 3 , 3 ]
169+ assert $ (alterAt 0 (Just <<< (_ + 1 )) [1 , 2 , 3 ]) == Just [2 , 2 , 3 ]
170+ assert $ (alterAt 1 (Just <<< (_ + 1 )) [1 , 2 , 3 ]) == Just [1 , 3 , 3 ]
170171
171172 log " alterAt should drop an item at the specified index when the function returns Nothing"
172173 assert $ (alterAt 0 (const Nothing ) [1 , 2 , 3 ]) == Just [2 , 3 ]
173174 assert $ (alterAt 1 (const Nothing ) [1 , 2 , 3 ]) == Just [1 , 3 ]
174175
175176 log " alterAt should return Nothing if the index is out of range"
176- assert $ (alterAt 1 (Just <<< (+ 1 )) nil) == Nothing
177+ assert $ (alterAt 1 (Just <<< (_ + 1 )) nil) == Nothing
177178
178179 log " reverse should reverse the order of items in an array"
179180 assert $ (reverse [1 , 2 , 3 ]) == [3 , 2 , 1 ]
0 commit comments