on master help sign in
Move/reorg some code, use base ver instead of GHC
e36bfcfHarendra Kumar
src/Streamly/Internal/FileSystem/Event/Linux.hs+15−18
@@ -156,8 +156,7 @@ import Data.Functor.Identity (runIdentity)
156import Data.IntMap.Lazy (IntMap)
156import Data.IntMap.Lazy (IntMap)
157import Data.IORef (IORef, newIORef, readIORef, writeIORef, modifyIORef)
157import Data.IORef (IORef, newIORef, readIORef, writeIORef, modifyIORef)
158import Data.List.NonEmpty (NonEmpty)
158import Data.List.NonEmpty (NonEmpty)
159−
159+#if !(MIN_VERSION_base(4,11,0))
160−#if __GLASGOW_HASKELL__ < 808
161import Data.Semigroup (Semigroup(..))
160import Data.Semigroup (Semigroup(..))
162#endif
161#endif
163import Data.Word (Word8, Word32)
162import Data.Word (Word8, Word32)
@@ -230,19 +229,9 @@ setFlag mask status cfg@Config{..} =
230 in cfg {createFlags = flags}
229 in cfg {createFlags = flags}
231
230
232-------------------------------------------------------------------------------
231-------------------------------------------------------------------------------
233−-- Utilities
232+-- Settings
234-------------------------------------------------------------------------------
233-------------------------------------------------------------------------------
235
234
236−-- XXX we really do not know the path encoding, all we know is that it is "/"
237−-- separated bytes. So these may fail or convert the path in an unexpected
238−-- manner. We should ultimately remove all usage of these.
239−
240−toUtf8 :: MonadIO m => String -> m (Array Word8)
241−toUtf8 = A.fromStream . U.encodeUtf8 . S.fromList
242−
243−utf8ToString :: Array Word8 -> String
244−utf8ToString = runIdentity . S.toList . U.decodeUtf8' . A.toStream
245−
246-- | Watch the whole directory tree recursively instead of watching just one
235-- | Watch the whole directory tree recursively instead of watching just one
247-- level of directory.
236-- level of directory.
248--
237--
@@ -253,10 +242,6 @@ utf8ToString = runIdentity . S.toList . U.decodeUtf8' . A.toStream
253setRecursiveMode :: Bool -> Config -> Config
242setRecursiveMode :: Bool -> Config -> Config
254setRecursiveMode rec cfg@Config{} = cfg {watchRec = rec}
243setRecursiveMode rec cfg@Config{} = cfg {watchRec = rec}
255
244
256−-------------------------------------------------------------------------------
257−-- Settings
258−-------------------------------------------------------------------------------
259−
260foreign import capi
245foreign import capi
261 "sys/inotify.h value IN_DONT_FOLLOW" iN_DONT_FOLLOW :: Word32
246 "sys/inotify.h value IN_DONT_FOLLOW" iN_DONT_FOLLOW :: Word32
262
247
@@ -537,7 +522,10 @@ defaultConfig :: Config
537defaultConfig =
522defaultConfig =
538 setWhenExists AddIfExists
523 setWhenExists AddIfExists
539 $ setAllEvents On
524 $ setAllEvents On
525+ $ Config
540− $ Config {watchRec = True, createFlags = 0}
526+ { watchRec = True
527+ , createFlags = 0
528+ }
541
529
542-------------------------------------------------------------------------------
530-------------------------------------------------------------------------------
543-- Open an event stream
531-- Open an event stream
@@ -597,6 +585,15 @@ foreign import ccall unsafe
597 "sys/inotify.h inotify_add_watch" c_inotify_add_watch
585 "sys/inotify.h inotify_add_watch" c_inotify_add_watch
598 :: CInt -> CString -> CUInt -> IO CInt
586 :: CInt -> CString -> CUInt -> IO CInt
599
587
588+-- XXX we really do not know the path encoding, all we know is that it is "/"
589+-- separated bytes. So these may fail or convert the path in an unexpected
590+-- manner. We should ultimately remove all usage of these.
591+
592+toUtf8 :: MonadIO m => String -> m (Array Word8)
593+toUtf8 = A.fromStream . U.encodeUtf8 . S.fromList
594+
595+utf8ToString :: Array Word8 -> String
596+utf8ToString = runIdentity . S.toList . U.decodeUtf8' . A.toStream
600
597
601#if !MIN_VERSION_base(4,10,0)
598#if !MIN_VERSION_base(4,10,0)
602-- | Turn an existing Handle into a file descriptor. This function throws an
599-- | Turn an existing Handle into a file descriptor. This function throws an
test/Streamly/Test/FileSystem/Event.hs+3−3
@@ -31,8 +31,6 @@ import System.IO.Unsafe (unsafePerformIO)
31#endif
31#endif
32import Streamly.Internal.Data.Array.Storable.Foreign (Array)
32import Streamly.Internal.Data.Array.Storable.Foreign (Array)
33
33
34−import Test.Hspec
35−
36import qualified Data.List.NonEmpty as NonEmpty
34import qualified Data.List.NonEmpty as NonEmpty
37import qualified Data.Set as Set
35import qualified Data.Set as Set
38import qualified Streamly.Unicode.Stream as Unicode
36import qualified Streamly.Unicode.Stream as Unicode
@@ -55,6 +53,8 @@ import Data.Functor.Identity (runIdentity)
55import qualified Streamly.Internal.Unicode.Stream as U
53import qualified Streamly.Internal.Unicode.Stream as U
56#endif
54#endif
57
55
56+import Test.Hspec
57+
58-------------------------------------------------------------------------------
58-------------------------------------------------------------------------------
59-- Utilities
59-- Utilities
60-------------------------------------------------------------------------------
60-------------------------------------------------------------------------------
@@ -396,4 +396,4 @@ testDesc =
396main :: IO ()
396main :: IO ()
397main = do
397main = do
398 hSetBuffering stdout NoBuffering
398 hSetBuffering stdout NoBuffering
399− hspec $ sequence_ $ map driver testDesc
399+ hspec $ sequence_ $ map driver testDesc