@@ -241,7 +241,8 @@ import GHC.Ptr (Ptr(..))
241import Streamly.Internal.BaseCompat
241import Streamly.Internal.BaseCompat
242import Streamly.Internal.Data.Fold.Type (Fold(..))
242import Streamly.Internal.Data.Fold.Type (Fold(..))
243import Streamly.Internal.Data.Producer.Type (Producer (..))
243import Streamly.Internal.Data.Producer.Type (Producer (..))
244−import Streamly.Internal.Data.SVar.Type (adaptState)
244+import Streamly.Internal.Data.Stream.Serial (SerialT(..))
245+import Streamly.Internal.Data.SVar.Type (adaptState, defState)
245import Streamly.Internal.Data.Unfold.Type (Unfold(..))
246import Streamly.Internal.Data.Unfold.Type (Unfold(..))
246import Streamly.Internal.System.IO (arrayPayloadSize, defaultChunkSize)
247import Streamly.Internal.System.IO (arrayPayloadSize, defaultChunkSize)
247import System.IO.Unsafe (unsafePerformIO)
248import System.IO.Unsafe (unsafePerformIO)
@@ -1090,20 +1091,19 @@ data GetIndicesState contents start end st =
1090-- bounds.
1091-- bounds.
1092-- /Pre-release/
1093-- /Pre-release/
1093−{-# INLINE getIndices #-}
1094+{-# INLINE getIndicesD #-}
1094−getIndices :: (MonadIO m, Storable a) =>
1095+getIndicesD :: (MonadIO m, Storable a) =>
1095− Unfold m (Array a) Int -> Unfold m (Array a) a
1096+ D.Stream m Int -> Unfold m (Array a) a
1096−getIndices (Unfold stepi injecti) = Unfold step inject
1097+getIndicesD (D.Stream stepi sti) = Unfold step inject
1100− inject arr@(Array contents start (Ptr end) _) = do
1101+ inject (Array contents start (Ptr end) _) =
1102− return $ GetIndicesState contents start (Ptr end) st
1102+ return $ GetIndicesState contents start (Ptr end) sti
1104 {-# INLINE_LATE step #-}
1104 {-# INLINE_LATE step #-}
1105 step (GetIndicesState contents start end st) = do
1105 step (GetIndicesState contents start end st) = do
1106− r <- stepi st
1106+ r <- stepi defState st
1107 case r of
1107 case r of
1108 D.Yield i s -> do
1108 D.Yield i s -> do
1109 x <- liftIO $ getIndexPtr start end i
1109 x <- liftIO $ getIndexPtr start end i
@@ -1113,6 +1113,10 @@ getIndices (Unfold stepi injecti) = Unfold step inject
1113 liftIO $ touch contents
1113 liftIO $ touch contents
1114 return D.Stop
1114 return D.Stop
1116+{-# INLINE getIndices #-}
1117+getIndices :: (MonadIO m, Storable a) => SerialT m Int -> Unfold m (Array a) a
1118+getIndices (SerialT stream) = getIndicesD $ D.fromStreamK stream
1116-------------------------------------------------------------------------------
1120-------------------------------------------------------------------------------
1117-- Subarrays
1121-- Subarrays
1118-------------------------------------------------------------------------------
1122-------------------------------------------------------------------------------