on master help sign in
Use NonEmpty argument
c820371Harendra Kumar
src/Streamly/Internal/FileSystem/Event/Linux.hs+7−5
@@ -149,6 +149,7 @@ import Data.Bits ((.|.), (.&.), complement)
149import Data.Foldable (foldlM)
149import Data.Foldable (foldlM)
150import Data.Functor.Identity (runIdentity)
150import Data.Functor.Identity (runIdentity)
151import Data.IntMap.Lazy (IntMap)
151import Data.IntMap.Lazy (IntMap)
152+import Data.List.NonEmpty (NonEmpty)
152import Data.Word (Word8, Word32)
153import Data.Word (Word8, Word32)
153import Foreign.C.Error (throwErrnoIfMinus1)
154import Foreign.C.Error (throwErrnoIfMinus1)
154import Foreign.C.String (CString)
155import Foreign.C.String (CString)
@@ -172,8 +173,8 @@ import GHC.IO.Handle.Types (Handle__(..), Handle(FileHandle, DuplexHandle))
172import GHC.IO.Handle.FD (handleToFd)
173import GHC.IO.Handle.FD (handleToFd)
173#endif
174#endif
174
175
175−
176import qualified Data.IntMap.Lazy as Map
176import qualified Data.IntMap.Lazy as Map
177+import qualified Data.List.NonEmpty as NonEmpty
177import qualified Streamly.Internal.Data.Fold as FL
178import qualified Streamly.Internal.Data.Fold as FL
178import qualified Streamly.Internal.Data.Parser as PR
179import qualified Streamly.Internal.Data.Parser as PR
179import qualified Streamly.Internal.Data.Stream.IsStream as S
180import qualified Streamly.Internal.Data.Stream.IsStream as S
@@ -619,10 +620,10 @@ removeFromWatch (Watch handle wdMap) path = do
619--
620--
620-- /Internal/
621-- /Internal/
621--
622--
622−openWatch :: Config -> [Array Word8] -> IO Watch
623+openWatch :: Config -> NonEmpty (Array Word8) -> IO Watch
623openWatch cfg paths = do
624openWatch cfg paths = do
624 w <- createWatch
625 w <- createWatch
625− foldlM (\w1 pth -> addToWatch cfg w1 pth) w paths
626+ foldlM (\w1 pth -> addToWatch cfg w1 pth) w (NonEmpty.toList paths)
626
627
627-- | Close a 'Watch' handle.
628-- | Close a 'Watch' handle.
628--
629--
@@ -731,7 +732,8 @@ watchToStream (Watch handle wdMap) =
731--
732--
732-- /Internal/
733-- /Internal/
733--
734--
735+watchPathsWith ::
734−watchPathsWith :: (Config -> Config) -> [Array Word8] -> SerialT IO Event
736+ (Config -> Config) -> NonEmpty (Array Word8) -> SerialT IO Event
735watchPathsWith f paths = S.bracket before after watchToStream
737watchPathsWith f paths = S.bracket before after watchToStream
736
738
737 where
739 where
@@ -747,7 +749,7 @@ watchPathsWith f paths = S.bracket before after watchToStream
747--
749--
748-- /Internal/
750-- /Internal/
749--
751--
750−watchPaths :: [Array Word8] -> SerialT IO Event
752+watchPaths :: NonEmpty (Array Word8) -> SerialT IO Event
751watchPaths = watchPathsWith id
753watchPaths = watchPathsWith id
752
754
753-------------------------------------------------------------------------------
755-------------------------------------------------------------------------------