on master help sign in
Use NonEmpty argument
commitc8203713ed266c8a04172dc3e80fcca7e58dc328 authorHarendra Kumar <harendra@composewell.com> dateWed 19 Aug 2020, 23:27 (6 years ago) parent3cdc73c
1 file changed+7−5
src/Streamly/Internal/FileSystem/Event/Linux.hs+7−5
src/Streamly/Internal/FileSystem/Event/Linux.hs+7−5
@@ -149,6 +149,7 @@ import Data.Bits ((.|.), (.&.), complement)
149149import Data.Foldable (foldlM)
150150import Data.Functor.Identity (runIdentity)
151151import Data.IntMap.Lazy (IntMap)
152+import Data.List.NonEmpty (NonEmpty)
152153import Data.Word (Word8, Word32)
153154import Foreign.C.Error (throwErrnoIfMinus1)
154155import Foreign.C.String (CString)
@@ -172,8 +173,8 @@ import GHC.IO.Handle.Types (Handle__(..), Handle(FileHandle, DuplexHandle))
172173import GHC.IO.Handle.FD (handleToFd)
173174#endif
174175
175−
176176import qualified Data.IntMap.Lazy as Map
177+import qualified Data.List.NonEmpty as NonEmpty
177178import qualified Streamly.Internal.Data.Fold as FL
178179import qualified Streamly.Internal.Data.Parser as PR
179180import qualified Streamly.Internal.Data.Stream.IsStream as S
@@ -619,10 +620,10 @@ removeFromWatch (Watch handle wdMap) path = do
619620--
620621-- /Internal/
621622--
622−openWatch :: Config -> [Array Word8] -> IO Watch
623+openWatch :: Config -> NonEmpty (Array Word8) -> IO Watch
623624openWatch cfg paths = do
624625 w <- createWatch
625− foldlM (\w1 pth -> addToWatch cfg w1 pth) w paths
626+ foldlM (\w1 pth -> addToWatch cfg w1 pth) w (NonEmpty.toList paths)
626627
627628-- | Close a 'Watch' handle.
628629--
@@ -731,7 +732,8 @@ watchToStream (Watch handle wdMap) =
731732--
732733-- /Internal/
733734--
734−watchPathsWith :: (Config -> Config) -> [Array Word8] -> SerialT IO Event
735+watchPathsWith ::
736+ (Config -> Config) -> NonEmpty (Array Word8) -> SerialT IO Event
735737watchPathsWith f paths = S.bracket before after watchToStream
736738
737739 where
@@ -747,7 +749,7 @@ watchPathsWith f paths = S.bracket before after watchToStream
747749--
748750-- /Internal/
749751--
750−watchPaths :: [Array Word8] -> SerialT IO Event
752+watchPaths :: NonEmpty (Array Word8) -> SerialT IO Event
751753watchPaths = watchPathsWith id
752754
753755-------------------------------------------------------------------------------