@@ -94,12 +94,11 @@ import Prelude hiding (read)
9494import qualified Control.Monad.Catch as MC
9595import qualified System.IO as SIO
9696
97−import Streamly.Data.Fold (chunksOf)
97+import Streamly.Data.Fold (chunksOf, drain)
9898import Streamly.Internal.Control.Concurrent (MonadAsync)
9999import Streamly.Internal.Data.Array.Unboxed.Type (Array(..), writeNUnsafe)
100100import Streamly.Internal.Data.Fold.Type (Fold(..))
101−import Streamly.Internal.Data.Stream.Type (Stream)
102−import Streamly.Internal.Data.Stream.IsStream.Type (IsStream)
101+import Streamly.Data.Stream (Stream)
103102import Streamly.Internal.Data.Unfold.Type (Unfold(..))
104103-- import Streamly.String (encodeUtf8, decodeUtf8, foldLines)
105104import Streamly.Internal.System.IO (defaultChunkSize)
@@ -111,7 +110,7 @@ import qualified Streamly.Internal.Data.Fold.Type as FL
111110import qualified Streamly.Internal.Data.Unfold as UF (bracket)
112111import qualified Streamly.Internal.FileSystem.Handle as FH
113112import qualified Streamly.Internal.Data.Array.Stream.Foreign as AS
114−import qualified Streamly.Internal.Data.Stream.IsStream as S
113+import qualified Streamly.Data.Stream as S (fold, bracket, mapM)
115114
116115-------------------------------------------------------------------------------
117116-- References
@@ -140,8 +139,8 @@ import qualified Streamly.Internal.Data.Stream.IsStream as S
140139-- /Pre-release/
141140--
142141{-# INLINE withFile #-}
143−withFile :: (IsStream t, MonadCatch m, MonadAsync m)
144− => FilePath -> IOMode -> (Handle -> t m a) -> t m a
142+withFile :: (MonadCatch m, MonadAsync m)
143+ => FilePath -> IOMode -> (Handle -> Stream m a) -> Stream m a
145144withFile file mode = S.bracket (liftIO $ openFile file mode) (liftIO . hClose)
146145
147146-- | Transform an 'Unfold' from a 'Handle' to an unfold from a 'FilePath'. The
@@ -219,8 +218,8 @@ appendArray file arr = SIO.withFile file AppendMode (`FH.putChunk` arr)
219218--
220219-- @since 0.9.0
221220{-# INLINE toChunksWith #-}
222−toChunksWith :: (IsStream t, MonadCatch m, MonadAsync m)
223− => Int -> FilePath -> t m (Array Word8)
221+toChunksWith :: (MonadCatch m, MonadAsync m)
222+ => Int -> FilePath -> Stream m (Array Word8)
224223toChunksWith size file =
225224 withFile file ReadMode (FH.getChunksWith size)
226225
@@ -234,8 +233,8 @@ toChunksWith size file =
234233--
235234-- @since 0.7.0
236235{-# INLINE toChunks #-}
237−toChunks :: (IsStream t, MonadCatch m, MonadAsync m)
238− => FilePath -> t m (Array Word8)
236+toChunks :: (MonadCatch m, MonadAsync m)
237+ => FilePath -> Stream m (Array Word8)
239238toChunks = toChunksWith defaultChunkSize
240239
241240-------------------------------------------------------------------------------
@@ -306,7 +305,7 @@ read = UF.many A.read (usingFile FH.readChunks)
306305-- /Pre-release/
307306--
308307{-# INLINE toBytes #-}
309−toBytes :: (IsStream t, MonadCatch m, MonadAsync m) => FilePath -> t m Word8
308+toBytes :: (MonadCatch m, MonadAsync m) => FilePath -> Stream m Word8
310309toBytes file = AS.concat $ withFile file ReadMode FH.getChunks
311310
312311{-
@@ -316,7 +315,7 @@ toBytes file = AS.concat $ withFile file ReadMode FH.getChunks
316315--
317316-- @since 0.7.0
318317{-# INLINE readShared #-}
319−readShared :: (IsStream t, MonadIO m) => Handle -> t m Word8
318+readShared :: MonadIO m => Handle -> Stream m Word8
320319readShared = undefined
321320-}
322321
@@ -327,7 +326,7 @@ readShared = undefined
327326{-# INLINE fromChunksMode #-}
328327fromChunksMode :: (MonadAsync m, MonadCatch m)
329328 => IOMode -> FilePath -> Stream m (Array a) -> m ()
330−fromChunksMode mode file xs = S.drain $
329+fromChunksMode mode file xs = S.fold drain $
331330 withFile file mode (\h -> S.mapM (FH.putChunk h) xs)
332331
333332-- | Write a stream of arrays to a file. Overwrites the file if it exists.
@@ -470,7 +469,7 @@ appendShared = undefined
470469--
471470-- @since 0.7.0
472471{-# INLINE readUtf8 #-}
473−readUtf8 :: (IsStream t, MonadIO m) => Handle -> t m Char
472+readUtf8 :: MonadIO m => Handle -> Stream m Char
474473readUtf8 = decodeUtf8 . read
475474
476475-- |
@@ -492,7 +491,7 @@ writeUtf8 h s = write h $ encodeUtf8 s
492491--
493492-- @since 0.7.0
494493{-# INLINE writeUtf8ByLines #-}
495−writeUtf8ByLines :: (IsStream t, MonadIO m) => Handle -> t m Char -> m ()
494+writeUtf8ByLines :: MonadIO m => Handle -> Stream m Char -> m ()
496495writeUtf8ByLines = undefined
497496
498497-- | Read UTF-8 lines from a file handle and apply the specified fold to each
@@ -500,7 +499,7 @@ writeUtf8ByLines = undefined
500499--
501500-- @since 0.7.0
502501{-# INLINE readLines #-}
503−readLines :: (IsStream t, MonadIO m) => Handle -> Fold m Char b -> t m b
502+readLines :: MonadIO m => Handle -> Fold m Char b -> Stream m b
504503readLines h f = foldLines (readUtf8 h) f
505504
506505-------------------------------------------------------------------------------
@@ -513,8 +512,8 @@ readLines h f = foldLines (readUtf8 h) f
513512--
514513-- @since 0.7.0
515514{-# INLINE readFrames #-}
516−readFrames :: (IsStream t, MonadIO m, Storable a)
517− => Array a -> Handle -> Fold m a b -> t m b
515+readFrames :: (MonadIO m, Storable a)
516+ => Array a -> Handle -> Fold m a b -> Stream m b
518517readFrames = undefined -- foldFrames . read
519518
520519-- | Write a stream to the given file handle buffering up to frames separated
@@ -522,8 +521,8 @@ readFrames = undefined -- foldFrames . read
522521--
523522-- @since 0.7.0
524523{-# INLINE writeByFrames #-}
525−writeByFrames :: (IsStream t, MonadIO m, Storable a)
526− => Array a -> Handle -> t m a -> m ()
524+writeByFrames :: (MonadIO m, Storable a)
525+ => Array a -> Handle -> Stream m a -> m ()
527526writeByFrames = undefined
528527
529528-------------------------------------------------------------------------------
@@ -560,8 +559,8 @@ readIndex arr i = undefined
560559-- chunk is aligned with @chunkSize@ from second chunk onwards.
561560--
562561{-# INLINE readSliceWith #-}
563−readSliceWith :: (IsStream t, MonadIO m, Storable a)
564− => Int -> Handle -> Int -> Int -> t m a
562+readSliceWith :: (MonadIO m, Storable a)
563+ => Int -> Handle -> Int -> Int -> Stream m a
565564readSliceWith chunkSize h pos len = undefined
566565
567566-- | @readSlice h i count@ streams a slice from the file handle @h@ starting
@@ -570,8 +569,8 @@ readSliceWith chunkSize h pos len = undefined
570569--
571570-- @since 0.7.0
572571{-# INLINE readSlice #-}
573−readSlice :: (IsStream t, MonadIO m, Storable a)
574− => Handle -> Int -> Int -> t m a
572+readSlice :: (MonadIO m, Storable a)
573+ => Handle -> Int -> Int -> Stream m a
575574readSlice = readSliceWith defaultChunkSize
576575
577576-- | @readSliceRev h i count@ streams a slice from the file handle @h@ starting
@@ -580,8 +579,8 @@ readSlice = readSliceWith defaultChunkSize
580579--
581580-- @since 0.7.0
582581{-# INLINE readSliceRev #-}
583−readSliceRev :: (IsStream t, MonadIO m, Storable a)
584− => Handle -> Int -> Int -> t m a
582+readSliceRev :: (MonadIO m, Storable a)
583+ => Handle -> Int -> Int -> Stream m a
585584readSliceRev h i count = undefined
586585
587586-- | Write the given element at the given index in the file.
@@ -597,8 +596,8 @@ writeIndex h i a = undefined
597596--
598597-- @since 0.7.0
599598{-# INLINE writeSlice #-}
600−writeSlice :: (IsStream t, Monad m, Storable a)
601− => Handle -> Int -> Int -> t m a -> m ()
599+writeSlice :: (Monad m, Storable a)
600+ => Handle -> Int -> Int -> Stream m a -> m ()
602601writeSlice h i len s = undefined
603602
604603-- | @writeSliceRev h i count stream@ writes a stream to the file handle @h@
@@ -607,7 +606,7 @@ writeSlice h i len s = undefined
607606--
608607-- @since 0.7.0
609608{-# INLINE writeSliceRev #-}
610−writeSliceRev :: (IsStream t, Monad m, Storable a)
611− => Handle -> Int -> Int -> t m a -> m ()
609+writeSliceRev :: (Monad m, Storable a)
610+ => Handle -> Int -> Int -> Stream m a -> m ()
612611writeSliceRev arr i len s = undefined
613612-}