@@ -571,49 +571,3 @@ traverse' f = \ !ary ->
571
571
(f x) (go (i + 1 ))
572
572
in runSTA len <$> go 0
573
573
{-# INLINE [1] traverse' #-}
574
-
575
- -- Traversing in ST, we don't need to get fancy; we
576
- -- can just do it directly.
577
- traverseST :: (a -> ST s b ) -> Array a -> ST s (Array b )
578
- traverseST f = \ ary0 ->
579
- let
580
- ! len = length ary0
581
- go k ! mary
582
- | k == len = return mary
583
- | otherwise = do
584
- x <- indexM ary0 k
585
- y <- f x
586
- write mary k y
587
- go (k + 1 ) mary
588
- in new_ len >>= (go 0 >=> unsafeFreeze)
589
- {-# INLINE traverseST #-}
590
-
591
- traverseIO :: (a -> IO b ) -> Array a -> IO (Array b )
592
- traverseIO f = \ ary0 ->
593
- let
594
- ! len = length ary0
595
- go k ! mary
596
- | k == len = return mary
597
- | otherwise = do
598
- x <- stToIO $ indexM ary0 k
599
- y <- f x
600
- stToIO $ write mary k y
601
- go (k + 1 ) mary
602
- in stToIO (new_ len) >>= (go 0 >=> stToIO . unsafeFreeze)
603
- {-# INLINE traverseIO #-}
604
-
605
-
606
- -- Why don't we have similar RULES for traverse'? The efficient
607
- -- way to traverse strictly in IO or ST is to force results as
608
- -- they come in, which leads to different semantics. In particular,
609
- -- we need to ensure that
610
- --
611
- -- traverse' (\x -> print x *> pure undefined) xs
612
- --
613
- -- will actually print all the values and then return undefined.
614
- -- We could add a strict mapMWithIndex, operating in an arbitrary
615
- -- Monad, that supported such rules, but we don't have that right now.
616
- {-# RULES
617
- "traverse/ST" forall f. traverse f = traverseST f
618
- "traverse/IO" forall f. traverse f = traverseIO f
619
- #-}
0 commit comments