@@ -5,10 +5,11 @@ import Prelude
5
5
import Control.Monad.Eff (Eff )
6
6
import Control.Monad.Eff.Console (log , CONSOLE )
7
7
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 )
9
9
import Data.Foldable (for_ , foldMapDefaultR , class Foldable , all )
10
10
import Data.Maybe (Maybe (..), isNothing , fromJust )
11
11
import Data.Tuple (Tuple (..))
12
+ import Data.Unfoldable (replicate , replicateA )
12
13
13
14
import Partial.Unsafe (unsafePartial )
14
15
@@ -32,15 +33,15 @@ testArray = do
32
33
assert $ replicate 0 " foo" == []
33
34
assert $ replicate (-1 ) " foo" == []
34
35
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 []
40
41
41
- log " replicateM should be stack safe"
42
+ log " replicateA should be stack safe"
42
43
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 )
44
45
45
46
-- some
46
47
-- many
@@ -165,15 +166,15 @@ testArray = do
165
166
assert $ (modifyAt 1 (_ + 1 ) nil) == Nothing
166
167
167
168
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 ]
170
171
171
172
log " alterAt should drop an item at the specified index when the function returns Nothing"
172
173
assert $ (alterAt 0 (const Nothing ) [1 , 2 , 3 ]) == Just [2 , 3 ]
173
174
assert $ (alterAt 1 (const Nothing ) [1 , 2 , 3 ]) == Just [1 , 3 ]
174
175
175
176
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
177
178
178
179
log " reverse should reverse the order of items in an array"
179
180
assert $ (reverse [1 , 2 , 3 ]) == [3 , 2 , 1 ]
0 commit comments