Skip to content

Commit 06b8c5b

Browse files
Remove ReadOptions from read and reader
1 parent 18b9c69 commit 06b8c5b

File tree

5 files changed

+14
-19
lines changed

5 files changed

+14
-19
lines changed

core/src/Streamly/Internal/FileSystem/Dir.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ pMapUnfoldE = fmap ePathMap . Unfold.lmapM Path.fromString
136136
--
137137
{-# INLINE reader #-}
138138
reader :: (MonadIO m, MonadCatch m) => Unfold m FilePath FilePath
139-
reader = fmap Path.toString $ Unfold.lmapM Path.fromString (DirIO.reader CONF)
139+
reader = fmap Path.toString $ Unfold.lmapM Path.fromString DirIO.reader
140140

141141
-- | Read directories as Left and files as Right. Filter out "." and ".."
142142
-- entries.

core/src/Streamly/Internal/FileSystem/DirIO.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,9 @@ dirReader f = fmap (fromLeft undefined) $ UF.filter isLeft (eitherReader f)
331331
--
332332
-- /Pre-release/
333333
{-# INLINE read #-}
334-
read :: (MonadIO m, MonadCatch m) => (ReadOptions -> ReadOptions) ->
334+
read :: (MonadIO m, MonadCatch m) =>
335335
Path -> Stream m Path
336-
read f = S.unfold (reader f)
336+
read = S.unfold reader
337337

338338
-- | Read directories as Left and files as Right. Filter out "." and ".."
339339
-- entries. The output contains the names of the directories and files.

core/src/Streamly/Internal/FileSystem/Posix/ReadDir.hsc

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,8 @@ streamEitherReader confMod = Unfold step return
378378
Just x -> return $ Yield x s
379379

380380
{-# INLINE streamReader #-}
381-
streamReader
382-
:: MonadIO m
383-
=> (ReadOptions -> ReadOptions) -> Unfold m (PosixPath, DirStream) Path
384-
streamReader confMod = fmap (either id id) (streamEitherReader confMod)
381+
streamReader :: MonadIO m => Unfold m (PosixPath, DirStream) Path
382+
streamReader = fmap (either id id) (streamEitherReader id)
385383

386384
{-# INLINE before #-}
387385
before :: PosixPath -> IO (PosixPath, DirStream)
@@ -397,14 +395,13 @@ after (_, dirStream) = closeDirStream dirStream
397395
-- /Internal/
398396
--
399397
{-# INLINE reader #-}
400-
reader :: (MonadIO m, MonadCatch m)
401-
=> (ReadOptions -> ReadOptions) -> Unfold m Path Path
402-
reader confMod =
398+
reader :: (MonadIO m, MonadCatch m) => Unfold m Path Path
399+
reader =
403400
-- XXX Instead of using bracketIO for each iteration of the loop we should
404401
-- instead yield a buffer of dir entries in each iteration and then use an
405402
-- unfold and concat to flatten those entries. That should improve the
406403
-- performance.
407-
UF.bracketIO before after (streamReader confMod)
404+
UF.bracketIO before after (streamReader)
408405

409406
-- | Read directories as Left and files as Right. Filter out "." and ".."
410407
-- entries.

core/src/Streamly/Internal/FileSystem/Windows/ReadDir.hsc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,24 +240,22 @@ streamEitherReader f = Unfold step return
240240
Just x -> return $ Yield x strm
241241

242242
{-# INLINE streamReader #-}
243-
streamReader :: MonadIO m =>
244-
(ReadOptions -> ReadOptions) -> Unfold m DirStream Path
245-
streamReader f = fmap (either id id) (streamEitherReader f)
243+
streamReader :: MonadIO m => Unfold m DirStream Path
244+
streamReader = fmap (either id id) (streamEitherReader id)
246245

247246
-- | Read a directory emitting a stream with names of the children. Filter out
248247
-- "." and ".." entries.
249248
--
250249
-- /Internal/
251250

252251
{-# INLINE reader #-}
253-
reader :: (MonadIO m, MonadCatch m) =>
254-
(ReadOptions -> ReadOptions) -> Unfold m Path Path
255-
reader f =
252+
reader :: (MonadIO m, MonadCatch m) => Unfold m Path Path
253+
reader =
256254
-- XXX Instead of using bracketIO for each iteration of the loop we should
257255
-- instead yield a buffer of dir entries in each iteration and then use an
258256
-- unfold and concat to flatten those entries. That should improve the
259257
-- performance.
260-
UF.bracketIO openDirStream closeDirStream (streamReader f)
258+
UF.bracketIO openDirStream closeDirStream streamReader
261259

262260
-- | Read directories as Left and files as Right. Filter out "." and ".."
263261
-- entries.

docs/User/Tutorials/module-structure-and-quick-examples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ import qualified Streamly.Console.Stdio as Console
421421
import qualified Streamly.FileSystem.FileIO as File
422422

423423
main =
424-
Dir.read id [path|.|] -- Stream IO Path
424+
Dir.read [path|.|] -- Stream IO Path
425425
& Stream.concatMap File.readChunks -- Stream IO (Array Word8)
426426
& Console.putChunks -- IO ()
427427
```

0 commit comments

Comments
 (0)