@@ -3,19 +3,21 @@ module Test.Data.List.Lazy (testListLazy) where
3
3
import Prelude
4
4
5
5
import Control.Lazy (defer )
6
- import Effect (Effect )
7
- import Effect.Console (log )
8
6
import Data.FoldableWithIndex (foldMapWithIndex , foldlWithIndex , foldrWithIndex )
9
7
import Data.FunctorWithIndex (mapWithIndex )
10
8
import Data.Lazy as Z
11
- import Data.List.Lazy (List , nil , stripPrefix , Pattern (..), cons , foldl , foldr , foldMap , singleton , transpose , take , iterate , filter , uncons , foldM , foldrLazy , range , unzip , zip , length , zipWithA , replicate , repeat , zipWith , intersectBy , intersect , deleteBy , delete , unionBy , union , nubBy , nub , groupBy , group , partition , span , dropWhile , drop , takeWhile , slice , catMaybes , mapMaybe , filterM , concat , concatMap , reverse , alterAt , modifyAt , updateAt , deleteAt , insertAt , findLastIndex , findIndex , elemLastIndex , elemIndex , init , tail , last , head , insertBy , insert , snoc , null , replicateM , fromFoldable , (:), (\\), (!! ))
9
+ import Data.List.Lazy (List , Pattern (..), alterAt , catMaybes , concat , concatMap , cons , delete , deleteAt , deleteBy , drop , dropWhile , elemIndex , elemLastIndex , filter , filterM , findIndex , findLastIndex , foldM , foldMap , foldl , foldr , foldrLazy , fromFoldable , group , groupBy , head , init , insert , insertAt , insertBy , intersect , intersectBy , iterate , last , length , mapMaybe , modifyAt , nil , nub , nubBy , null , partition , range , repeat , replicate , replicateM , reverse , singleton , slice , snoc , span , stripPrefix , tail , take , takeWhile , transpose , uncons , union , unionBy , unzip , updateAt , zip , zipWith , zipWithA , (!!), (..) , (:), (\\))
12
10
import Data.List.Lazy.NonEmpty as NEL
13
11
import Data.Maybe (Maybe (..), isNothing , fromJust )
14
12
import Data.Monoid.Additive (Additive (..))
15
13
import Data.NonEmpty ((:|))
16
14
import Data.Traversable (traverse )
17
15
import Data.TraversableWithIndex (traverseWithIndex )
18
16
import Data.Tuple (Tuple (..))
17
+ import Data.Unfoldable (unfoldr )
18
+ import Data.Unfoldable1 (unfoldr1 )
19
+ import Effect (Effect )
20
+ import Effect.Console (log )
19
21
import Partial.Unsafe (unsafePartial )
20
22
import Test.Assert (assert )
21
23
@@ -396,9 +398,26 @@ testListLazy = do
396
398
((10 :20 :30 :nil) : (11 :31 :nil) : (32 :nil) : nil)
397
399
log " transpose nil == nil"
398
400
assert $ transpose nil == (nil :: List (List Int ))
401
+
399
402
log " transpose (singleton nil) == nil"
400
403
assert $ transpose (singleton nil) == (nil :: List (List Int ))
401
404
405
+ log " unfoldr should maintain order"
406
+ assert $ (1 ..5 ) == unfoldr step 1
407
+
408
+ log " unfoldr1 should maintain order"
409
+ assert $ (1 ..5 ) == unfoldr1 step1 1
410
+
411
+ log " map should maintain order"
412
+ assert $ (1 ..5 ) == map identity (1 ..5 )
413
+
414
+ step :: Int -> Maybe (Tuple Int Int )
415
+ step 6 = Nothing
416
+ step n = Just (Tuple n (n + 1 ))
417
+
418
+ step1 :: Int -> Tuple Int (Maybe Int )
419
+ step1 n = Tuple n (if n >= 5 then Nothing else Just (n + 1 ))
420
+
402
421
nil' :: List Int
403
422
nil' = nil
404
423
0 commit comments