@@ -43,6 +43,8 @@ import qualified Streamly.FileSystem.Handle as FH
43import qualified Streamly.Memory.Array as A
43import qualified Streamly.Memory.Array as A
44import qualified Streamly.Prelude as S
44import qualified Streamly.Prelude as S
45import qualified Streamly.Data.String as SS
45import qualified Streamly.Data.String as SS
47+import qualified Streamly.Internal.FileSystem.Handle as IFH
46import qualified Streamly.Internal.Prelude as Internal
48import qualified Streamly.Internal.Prelude as Internal
47import qualified Streamly.Internal.Memory.Array as IA
49import qualified Streamly.Internal.Memory.Array as IA
48import qualified Streamly.Internal.Memory.ArrayStream as AS
50import qualified Streamly.Internal.Memory.ArrayStream as AS
@@ -57,7 +59,7 @@ import Test.Inspection
57{-# INLINE last #-}
59{-# INLINE last #-}
58last :: Handle -> IO (Maybe Word8)
60last :: Handle -> IO (Maybe Word8)
59last inh = do
61last inh = do
60− let s = FH.readArrays inh
62+ let s = IFH.readArrays inh
61 larr <- S.last s
63 larr <- S.last s
62 return $ case larr of
64 return $ case larr of
63 Nothing -> Nothing
65 Nothing -> Nothing
@@ -72,7 +74,7 @@ inspect $ 'last `hasNoType` ''Step
72{-# INLINE countBytes #-}
74{-# INLINE countBytes #-}
73countBytes :: Handle -> IO Int
75countBytes :: Handle -> IO Int
74countBytes inh =
76countBytes inh =
75− let s = FH.readArrays inh
77+ let s = IFH.readArrays inh
76 in S.sum (S.map A.length s)
78 in S.sum (S.map A.length s)
78#ifdef INSPECTION
80#ifdef INSPECTION
@@ -83,7 +85,7 @@ inspect $ 'countBytes `hasNoType` ''Step
83-- | Count the number of lines in a file.
85-- | Count the number of lines in a file.
84{-# INLINE countLines #-}
86{-# INLINE countLines #-}
85countLines :: Handle -> IO Int
87countLines :: Handle -> IO Int
86−countLines = S.length . AS.splitOnSuffix 10 . FH.readArrays
88+countLines = S.length . AS.splitOnSuffix 10 . IFH.readArrays
88#ifdef INSPECTION
90#ifdef INSPECTION
89inspect $ hasNoTypeClasses 'countLines
91inspect $ hasNoTypeClasses 'countLines
@@ -94,7 +96,7 @@ inspect $ 'countLines `hasNoType` ''Step
94-- | Count the number of lines in a file.
96-- | Count the number of lines in a file.
95{-# INLINE countWords #-}
97{-# INLINE countWords #-}
96countWords :: Handle -> IO Int
98countWords :: Handle -> IO Int
97−countWords = S.length . AS.splitOn 32 . FH.readArrays
99+countWords = S.length . AS.splitOn 32 . IFH.readArrays
99#ifdef INSPECTION
101#ifdef INSPECTION
100inspect $ hasNoTypeClasses 'countWords
102inspect $ hasNoTypeClasses 'countWords
@@ -106,7 +108,7 @@ inspect $ 'countWords `hasNoType` ''Step
106sumBytes :: Handle -> IO Word8
108sumBytes :: Handle -> IO Word8
107sumBytes inh = do
109sumBytes inh = do
108 let foldlArr' f z = runIdentity . S.foldl' f z . IA.toStream
110 let foldlArr' f z = runIdentity . S.foldl' f z . IA.toStream
109− let s = FH.readArrays inh
111+ let s = IFH.readArrays inh
110 S.foldl' (\acc arr -> acc + foldlArr' (+) 0 arr) 0 s
112 S.foldl' (\acc arr -> acc + foldlArr' (+) 0 arr) 0 s
112#ifdef INSPECTION
114#ifdef INSPECTION
@@ -118,7 +120,7 @@ inspect $ 'sumBytes `hasNoType` ''Step
118{-# INLINE cat #-}
120{-# INLINE cat #-}
119cat :: Handle -> Handle -> IO ()
121cat :: Handle -> Handle -> IO ()
120cat devNull inh =
122cat devNull inh =
121− S.fold (FH.writeArrays devNull) $ FH.readArraysOf (256*1024) inh
123+ S.fold (IFH.writeArrays devNull) $ IFH.readArraysOf (256*1024) inh
123#ifdef INSPECTION
125#ifdef INSPECTION
124inspect $ hasNoTypeClasses 'cat
126inspect $ hasNoTypeClasses 'cat
@@ -129,8 +131,8 @@ inspect $ 'cat `hasNoType` ''Step
129{-# INLINE copy #-}
131{-# INLINE copy #-}
130copy :: Handle -> Handle -> IO ()
132copy :: Handle -> Handle -> IO ()
131copy inh outh =
133copy inh outh =
132− let s = FH.readArrays inh
134+ let s = IFH.readArrays inh
133− in S.fold (FH.writeArrays outh) s
135+ in S.fold (IFH.writeArrays outh) s
135#ifdef INSPECTION
137#ifdef INSPECTION
136inspect $ hasNoTypeClasses 'copy
138inspect $ hasNoTypeClasses 'copy
@@ -141,10 +143,10 @@ inspect $ 'copy `hasNoType` ''Step
141{-# INLINE linesUnlinesCopy #-}
143{-# INLINE linesUnlinesCopy #-}
142linesUnlinesCopy :: Handle -> Handle -> IO ()
144linesUnlinesCopy :: Handle -> Handle -> IO ()
143linesUnlinesCopy inh outh =
145linesUnlinesCopy inh outh =
144− S.fold (FH.writeArraysInChunksOf (1024*1024) outh)
146+ S.fold (IFH.writeArraysInChunksOf (1024*1024) outh)
145 $ Internal.insertAfterEach (return $ A.fromList [10])
147 $ Internal.insertAfterEach (return $ A.fromList [10])
146 $ AS.splitOnSuffix 10
148 $ AS.splitOnSuffix 10
147− $ FH.readArraysOf (1024*1024) inh
149+ $ IFH.readArraysOf (1024*1024) inh
149#ifdef INSPECTION
151#ifdef INSPECTION
150inspect $ hasNoTypeClassesExcept 'linesUnlinesCopy [''Storable]
152inspect $ hasNoTypeClassesExcept 'linesUnlinesCopy [''Storable]
@@ -155,11 +157,11 @@ inspect $ hasNoTypeClassesExcept 'linesUnlinesCopy [''Storable]
155{-# INLINE wordsUnwordsCopy #-}
157{-# INLINE wordsUnwordsCopy #-}
156wordsUnwordsCopy :: Handle -> Handle -> IO ()
158wordsUnwordsCopy :: Handle -> Handle -> IO ()
157wordsUnwordsCopy inh outh =
159wordsUnwordsCopy inh outh =
158− S.fold (FH.writeArraysInChunksOf (1024*1024) outh)
160+ S.fold (IFH.writeArraysInChunksOf (1024*1024) outh)
159 $ S.intersperse (A.fromList [32])
161 $ S.intersperse (A.fromList [32])
160 -- XXX use a word splitting combinator
162 -- XXX use a word splitting combinator
161 $ AS.splitOn 32
163 $ AS.splitOn 32
162− $ FH.readArraysOf (1024*1024) inh
164+ $ IFH.readArraysOf (1024*1024) inh
164#ifdef INSPECTION
166#ifdef INSPECTION
165inspect $ hasNoTypeClassesExcept 'wordsUnwordsCopy [''Storable]
167inspect $ hasNoTypeClassesExcept 'wordsUnwordsCopy [''Storable]
@@ -171,7 +173,7 @@ decodeUtf8Lenient :: Handle -> IO ()
171decodeUtf8Lenient inh =
173decodeUtf8Lenient inh =
173 $ SS.decodeUtf8ArraysLenient
175 $ SS.decodeUtf8ArraysLenient
174− $ FH.readArraysOf (1024*1024) inh
176+ $ IFH.readArraysOf (1024*1024) inh
176#ifdef INSPECTION
178#ifdef INSPECTION
177inspect $ hasNoTypeClasses 'decodeUtf8Lenient
179inspect $ hasNoTypeClasses 'decodeUtf8Lenient
@@ -187,7 +189,7 @@ copyCodecUtf8Lenient inh outh =
187 S.fold (FH.write outh)
189 S.fold (FH.write outh)
188 $ SS.encodeUtf8
190 $ SS.encodeUtf8
189 $ SS.decodeUtf8ArraysLenient
191 $ SS.decodeUtf8ArraysLenient
190− $ FH.readArraysOf (1024*1024) inh
192+ $ IFH.readArraysOf (1024*1024) inh
192#ifdef INSPECTION
194#ifdef INSPECTION
193inspect $ hasNoTypeClasses 'copyCodecUtf8Lenient
195inspect $ hasNoTypeClasses 'copyCodecUtf8Lenient