@@ -119,8 +119,8 @@ module Streamly.Internal.Data.Array.Mut.Type
119119 , toStreamDRevWith
120120 , toStreamKWith
121121 , toStreamKRevWith
122− , toStreamD
123− , toStreamDRev
122+ , read
123+ , readRev
124124 , toStreamK
125125 , toStreamKRev
126126 , toList
@@ -526,6 +526,8 @@ putIndices arr = FL.foldlM' step (return ())
526526
527527-- | Modify a given index of an array using a modifier function.
528528--
529+-- Unsafe because it does not check the bounds of the array.
530+--
529531-- /Pre-release/
530532modifyIndexUnsafe :: forall m a b. (MonadIO m, Unbox a) =>
531533 Int -> MutArray a -> (a -> (a, b)) -> m b
@@ -552,7 +554,6 @@ modifyIndex i MutArray{..} f = do
552554 return res
553555 else invalidIndex "modifyIndex" i
554556
555−
556557-- | Modify the array indices generated by the supplied stream.
557558--
558559-- /Pre-release/
@@ -571,6 +572,8 @@ modifyIndices arr f = FL.foldlM' step initial
571572
572573-- | Modify each element of an array using the supplied modifier function.
573574--
575+-- This is an in-place equivalent of an immutable map operation.
576+--
574577-- /Pre-release/
575578modify :: forall m a. (MonadIO m, Unbox a)
576579 => MutArray a -> (a -> a) -> m ()
@@ -1549,14 +1552,13 @@ toStreamDWith liftio MutArray{..} = D.Stream step arrStart
15491552 r <- peekWith arrContents p
15501553 return $ D.Yield r (INDEX_NEXT(p,a))
15511554
1552−-- | Use the 'reader' unfold instead.
1555+-- | Convert a 'MutArray' into a stream.
15531556--
1554−-- @toStreamD = D.unfold reader@
1557+-- >>> read = Stream.unfold MutArray.reader
15551558--
1556−-- We can try this if the unfold has any performance issues.
1557−{-# INLINE_NORMAL toStreamD #-}
1558−toStreamD :: forall m a. (MonadIO m, Unbox a) => MutArray a -> D.Stream m a
1559−toStreamD = toStreamDWith liftIO
1559+{-# INLINE_NORMAL read #-}
1560+read :: forall m a. (MonadIO m, Unbox a) => MutArray a -> D.Stream m a
1561+read = toStreamDWith liftIO
15601562
15611563{-# INLINE toStreamKWith #-}
15621564toStreamKWith ::
@@ -1591,14 +1593,13 @@ toStreamDRevWith liftio MutArray{..} =
15911593 r <- peekWith arrContents p
15921594 return $ D.Yield r (INDEX_PREV(p,a))
15931595
1594−-- | Use the 'readerRev' unfold instead.
1596+-- | Convert a 'MutArray' into a stream in reverse order.
15951597--
1596−-- @toStreamDRev = D.unfold readerRev@
1598+-- >>> readRev = Stream.unfold MutArray.readerRev
15971599--
1598−-- We can try this if the unfold has any perf issues.
1599−{-# INLINE_NORMAL toStreamDRev #-}
1600−toStreamDRev :: forall m a. (MonadIO m, Unbox a) => MutArray a -> D.Stream m a
1601−toStreamDRev = toStreamDRevWith liftIO
1600+{-# INLINE_NORMAL readRev #-}
1601+readRev :: forall m a. (MonadIO m, Unbox a) => MutArray a -> D.Stream m a
1602+readRev = toStreamDRevWith liftIO
16021603
16031604{-# INLINE toStreamKRevWith #-}
16041605toStreamKRevWith ::
@@ -1629,12 +1630,12 @@ toStreamKRev = toStreamKRevWith liftIO
16291630-- | Strict left fold of an array.
16301631{-# INLINE_NORMAL foldl' #-}
16311632foldl' :: (MonadIO m, Unbox a) => (b -> a -> b) -> b -> MutArray a -> m b
1632−foldl' f z arr = D.foldl' f z $ toStreamD arr
1633+foldl' f z arr = D.foldl' f z $ read arr
16331634
16341635-- | Right fold of an array.
16351636{-# INLINE_NORMAL foldr #-}
16361637foldr :: (MonadIO m, Unbox a) => (a -> b -> b) -> b -> MutArray a -> m b
1637−foldr f z arr = D.foldr f z $ toStreamD arr
1638+foldr f z arr = D.foldr f z $ read arr
16381639
16391640-------------------------------------------------------------------------------
16401641-- Folds