@@ -52,31 +52,40 @@ testListLazy = do
5252
5353 log " foldlWithIndex should be correct"
5454 assert $ foldlWithIndex (\i b _ -> i + b) 0 (range 0 10000 ) == 50005000
55+ assert $ map (foldlWithIndex (\i b _ -> i + b) 0 ) (NEL .fromFoldable (range 0 10000 )) == Just 50005000
5556
5657 log " foldlWithIndex should be stack-safe"
5758 void $ pure $ foldlWithIndex (\i b _ -> i + b) 0 $ range 0 100000
59+ void $ pure $ map (foldlWithIndex (\i b _ -> i + b) 0 ) $ NEL .fromFoldable $ range 0 100000
5860
5961 log " foldrWithIndex should be correct"
6062 assert $ foldrWithIndex (\i _ b -> i + b) 0 (range 0 10000 ) == 50005000
63+ assert $ map (foldrWithIndex (\i _ b -> i + b) 0 ) (NEL .fromFoldable (range 0 10000 )) == Just 50005000
6164
6265 log " foldrWithIndex should be stack-safe"
6366 void $ pure $ foldrWithIndex (\i _ b -> i + b) 0 $ range 0 100000
67+ void $ pure $ map (foldrWithIndex (\i _ b -> i + b) 0 ) $ NEL .fromFoldable $ range 0 100000
6468
6569 log " foldMapWithIndex should be stack-safe"
6670 void $ pure $ foldMapWithIndex (\i _ -> Additive i) $ range 1 100000
71+ void $ pure $ map (foldMapWithIndex (\i _ -> Additive i)) $ NEL .fromFoldable $ range 1 100000
6772
6873 log " foldMapWithIndex should be left-to-right"
6974 assert $ foldMapWithIndex (\i _ -> show i) (fromFoldable [0 , 0 , 0 ]) == " 012"
75+ assert $ map (foldMapWithIndex (\i _ -> show i)) (NEL .fromFoldable [0 , 0 , 0 ]) == Just " 012"
7076
7177 log " traverse should be stack-safe"
7278 assert $ ((traverse Just longList) >>= last) == last longList
7379
7480 log " traverseWithIndex should be stack-safe"
7581 assert $ traverseWithIndex (const Just ) longList == Just longList
82+ assert $ traverseWithIndex (const Just ) (NEL .fromFoldable longList) == Just (NEL .fromFoldable longList)
7683
7784 log " traverseWithIndex should be correct"
7885 assert $ traverseWithIndex (\i a -> Just $ i + a) (fromFoldable [2 , 2 , 2 ])
7986 == Just (fromFoldable [2 , 3 , 4 ])
87+ assert $ map (traverseWithIndex (\i a -> Just $ i + a)) (NEL .fromFoldable [2 , 2 , 2 ])
88+ == Just (NEL .fromFoldable [2 , 3 , 4 ])
8089
8190 log " bind should be stack-safe"
8291 void $ pure $ last $ longList >>= pure
@@ -257,6 +266,7 @@ testListLazy = do
257266
258267 log " mapWithIndex should take a list of values and apply a function which also takes the index into account"
259268 assert $ mapWithIndex (\x ix -> x + ix) (fromFoldable [0 , 1 , 2 , 3 ]) == fromFoldable [0 , 2 , 4 , 6 ]
269+ assert $ map (mapWithIndex (\x ix -> x + ix)) (NEL .fromFoldable [0 , 1 , 2 , 3 ]) == NEL .fromFoldable [0 , 2 , 4 , 6 ]
260270
261271 -- log "sort should reorder a list into ascending order based on the result of compare"
262272 -- assert $ sort (l [1, 3, 2, 5, 6, 4]) == l [1, 2, 3, 4, 5, 6]
0 commit comments