@@ -121,7 +121,8 @@ import System.Win32.File
122import System.Win32.Types (BOOL, DWORD, HANDLE, LPVOID, LPDWORD, failIfFalse_)
122import System.Win32.Types (BOOL, DWORD, HANDLE, LPVOID, LPDWORD, failIfFalse_)
123import qualified Data.List.NonEmpty as NonEmpty
123import qualified Data.List.NonEmpty as NonEmpty
124−import qualified Streamly.Internal.Data.Stream.IsStream as S
124+import qualified Streamly.Data.Fold as Fold
125+import qualified Streamly.Internal.Data.Stream as S
125import qualified Streamly.Internal.Unicode.Stream as U
126import qualified Streamly.Internal.Unicode.Stream as U
126import qualified Streamly.Internal.Unicode.Utf8 as UTF8
127import qualified Streamly.Internal.Unicode.Utf8 as UTF8
127import qualified Streamly.Internal.Data.Array.Unboxed as A
128import qualified Streamly.Internal.Data.Array.Unboxed as A
@@ -416,7 +417,8 @@ eventStreamAggr :: (HANDLE, FilePath, Config) -> Stream IO Event
416eventStreamAggr (handle, rootPath, cfg) = do
417eventStreamAggr (handle, rootPath, cfg) = do
417 let recMode = getConfigRecMode cfg
418 let recMode = getConfigRecMode cfg
418 flagMasks = getConfigFlag cfg
419 flagMasks = getConfigFlag cfg
420+ repeatM = S.sequence . S.repeat
419− S.concatMap S.fromList $ S.repeatM
421+ S.concatMap S.fromList $ repeatM
420 $ readDirectoryChanges rootPath handle recMode flagMasks
422 $ readDirectoryChanges rootPath handle recMode flagMasks
422pathsToHandles ::
424pathsToHandles ::
@@ -424,14 +426,14 @@ pathsToHandles ::
424pathsToHandles paths cfg = do
426pathsToHandles paths cfg = do
425 let pathStream = S.fromList (NonEmpty.toList paths)
427 let pathStream = S.fromList (NonEmpty.toList paths)
426 st2 = S.mapM getWatchHandle pathStream
428 st2 = S.mapM getWatchHandle pathStream
427− S.map (\(h, f) -> (h, f, cfg)) st2
429+ fmap (\(h, f) -> (h, f, cfg)) st2
429-------------------------------------------------------------------------------
431-------------------------------------------------------------------------------
430-- Utilities
432-- Utilities
431-------------------------------------------------------------------------------
433-------------------------------------------------------------------------------
433utf8ToString :: Array Word8 -> FilePath
435utf8ToString :: Array Word8 -> FilePath
434−utf8ToString = runIdentity . S.toList . U.decodeUtf8 . A.toStream
436+utf8ToString = runIdentity . S.fold Fold.toList . U.decodeUtf8 . A.toStream
436utf8ToStringList :: NonEmpty (Array Word8) -> NonEmpty FilePath
438utf8ToStringList :: NonEmpty (Array Word8) -> NonEmpty FilePath
437utf8ToStringList = NonEmpty.map utf8ToString
439utf8ToStringList = NonEmpty.map utf8ToString
@@ -439,7 +441,9 @@ utf8ToStringList = NonEmpty.map utf8ToString
439-- | Close a Directory handle.
441-- | Close a Directory handle.
441closePathHandleStream :: Stream IO (HANDLE, FilePath, Config) -> IO ()
443closePathHandleStream :: Stream IO (HANDLE, FilePath, Config) -> IO ()
442−closePathHandleStream = S.mapM_ (\(h, _, _) -> closeHandle h)
444+closePathHandleStream =
445+ let f (h, _, _) = closeHandle h
446+ in S.fold (Fold.drainBy f)
445-- Document the path treatment for Linux/Windows/macOS modules.
449-- Document the path treatment for Linux/Windows/macOS modules.