@@ -1579,7 +1579,7 @@ isPrefixOf m1 m2 = D.isPrefixOf (toStreamD m1) (toStreamD m2)
1580{-# INLINE isSuffixOf #-}
1580{-# INLINE isSuffixOf #-}
1581isSuffixOf :: (Monad m, Eq a) => SerialT m a -> SerialT m a -> m Bool
1581isSuffixOf :: (Monad m, Eq a) => SerialT m a -> SerialT m a -> m Bool
1582−isSuffixOf suffix stream = isPrefixOf (reverse suffix) (reverse stream)
1582+isSuffixOf suffix stream = reverse suffix `isPrefixOf` reverse stream
1584-- | Returns 'True' if the first stream is an infix of the second. A stream is
1584-- | Returns 'True' if the first stream is an infix of the second. A stream is
1585-- considered an infix of itself.
1585-- considered an infix of itself.
@@ -1753,7 +1753,7 @@ toListRev = D.toListRev . toStreamD
1753{-# DEPRECATED toHandle
1753{-# DEPRECATED toHandle
1754 "Please use Streamly.FileSystem.Handle module (see the changelog)" #-}
1754 "Please use Streamly.FileSystem.Handle module (see the changelog)" #-}
1755toHandle :: MonadIO m => IO.Handle -> SerialT m String -> m ()
1755toHandle :: MonadIO m => IO.Handle -> SerialT m String -> m ()
1756−toHandle h m = go m
1756+toHandle h = go
1759 let stop = return ()
1759 let stop = return ()
@@ -3023,7 +3023,7 @@ concatMapIterateWith
3023 -> (a -> t m a)
3023 -> (a -> t m a)
3024 -> t m a
3024 -> t m a
3025 -> t m a
3025 -> t m a
3026−concatMapIterateWith combine f xs = concatMapWith combine go xs
3026+concatMapIterateWith combine f = concatMapWith combine go
3028 go x = yield x `combine` concatMapWith combine go (f x)
3028 go x = yield x `combine` concatMapWith combine go (f x)
@@ -3058,7 +3058,7 @@ concatMapTreeWith
3058 -> (a -> t m (Either a b))
3058 -> (a -> t m (Either a b))
3059 -> t m (Either a b) -- Should be t m a?
3059 -> t m (Either a b) -- Should be t m a?
3060 -> t m (Either a b)
3060 -> t m (Either a b)
3061−concatMapTreeWith combine f xs = concatMapWith combine go xs
3061+concatMapTreeWith combine f = concatMapWith combine go
3063 go (Left tree) = yield (Left tree) `combine` concatMapWith combine go (f tree)
3063 go (Left tree) = yield (Left tree) `combine` concatMapWith combine go (f tree)
3064 go (Right leaf) = yield $ Right leaf
3064 go (Right leaf) = yield $ Right leaf
@@ -3959,7 +3959,7 @@ pollCounts ::
3959pollCounts predicate transf f xs =
3959pollCounts predicate transf f xs =
3960 D.fromStreamD
3960 D.fromStreamD
3961 $ D.pollCounts predicate (D.toStreamD . transf . D.fromStreamD) f
3961 $ D.pollCounts predicate (D.toStreamD . transf . D.fromStreamD) f
3962− $ (D.toStreamD xs)
3962+ $ D.toStreamD xs
3964-- | Calls the supplied function with the number of elements consumed
3964-- | Calls the supplied function with the number of elements consumed
3965-- every @n@ seconds. The given function is run in a separate thread
3965-- every @n@ seconds. The given function is run in a separate thread
@@ -3985,7 +3985,7 @@ tapRate ::
3985 -> (Int -> m b)
3985 -> (Int -> m b)
3986 -> t m a
3986 -> t m a
3987 -> t m a
3987 -> t m a
3988−tapRate n f xs = D.fromStreamD $ D.tapRate n f $ (D.toStreamD xs)
3988+tapRate n f xs = D.fromStreamD $ D.tapRate n f $ D.toStreamD xs
3990-- | Apply a monadic function to each element flowing through the stream and
3990-- | Apply a monadic function to each element flowing through the stream and
3991-- discard the results.
3991-- discard the results.
@@ -4186,7 +4186,7 @@ classifySessionsBy
4186 -> t m (k, b) -- ^ session key, fold result
4186 -> t m (k, b) -- ^ session key, fold result
4187classifySessionsBy tick timeout reset ejectPred
4187classifySessionsBy tick timeout reset ejectPred
4188 (Fold step initial extract) str =
4188 (Fold step initial extract) str =
4189− concatMap (\session -> sessionOutputStream session)
4189+ concatMap sessionOutputStream
4190 $ scanlM' sstep szero stream
4190 $ scanlM' sstep szero stream
@@ -4213,7 +4213,7 @@ classifySessionsBy tick timeout reset ejectPred
4213 -- We use the first strategy as of now.
4213 -- We use the first strategy as of now.
4215 -- Got a new stream input element
4215 -- Got a new stream input element
4216− sstep (session@SessionState{..}) (Just (key, value, timestamp)) = do
4216+ sstep session@SessionState{..} (Just (key, value, timestamp)) = do
4217 -- XXX we should use a heap in pinned memory to scale it to a large
4217 -- XXX we should use a heap in pinned memory to scale it to a large
@@ -4273,7 +4273,7 @@ classifySessionsBy tick timeout reset ejectPred
4273 -- Insert the new session in heap
4273 -- Insert the new session in heap
4274 let expiry = addToAbsTime timestamp timeoutMs
4274 let expiry = addToAbsTime timestamp timeoutMs
4275 hp' = H.insert (Entry expiry key) hp
4275 hp' = H.insert (Entry expiry key) hp
4276− in return $ (hp', mp, out, (cnt + 1))
4276+ in return (hp', mp, out, cnt + 1)
4277 -- updating old entry
4277 -- updating old entry
4278 Just _ -> return vars
4278 Just _ -> return vars
@@ -4288,7 +4288,7 @@ classifySessionsBy tick timeout reset ejectPred
4290 -- Got a timer tick event
4290 -- Got a timer tick event
4291− sstep (sessionState@SessionState{..}) Nothing =
4291+ sstep sessionState@SessionState{..} Nothing =
4292 let curTime = addToAbsTime sessionCurTime tickMs
4292 let curTime = addToAbsTime sessionCurTime tickMs
4293 in ejectExpired sessionState curTime
4293 in ejectExpired sessionState curTime
@@ -4302,12 +4302,12 @@ classifySessionsBy tick timeout reset ejectPred
4302 sess <- extract acc
4302 sess <- extract acc
4303 let out1 = (key, fromEither sess) `K.cons` out
4303 let out1 = (key, fromEither sess) `K.cons` out
4304 let mp1 = Map.delete key mp
4304 let mp1 = Map.delete key mp
4305− return (hp, mp1, out1, (cnt - 1))
4305+ return (hp, mp1, out1, cnt - 1)
4307 ejectOne (hp, mp, out, !cnt) = do
4307 ejectOne (hp, mp, out, !cnt) = do
4308 let hres = H.uncons hp
4308 let hres = H.uncons hp
4309 case hres of
4309 case hres of
4310− Just (Entry expiry key, hp1) -> do
4310+ Just (Entry expiry key, hp1) ->
4311 case Map.lookup key mp of
4311 case Map.lookup key mp of
4312 Nothing -> ejectOne (hp1, mp, out, cnt)
4312 Nothing -> ejectOne (hp1, mp, out, cnt)
4313 Just (Tuple' latestTS acc) -> do
4313 Just (Tuple' latestTS acc) -> do
@@ -4322,7 +4322,7 @@ classifySessionsBy tick timeout reset ejectPred
4322 assert (Map.null mp) (return ())
4322 assert (Map.null mp) (return ())
4323 return (hp, mp, out, cnt)
4323 return (hp, mp, out, cnt)
4325− ejectExpired (session@SessionState{..}) curTime = do
4325+ ejectExpired session@SessionState{..} curTime = do
4326 (hp', mp', out, count) <-
4326 (hp', mp', out, count) <-
4327 ejectLoop sessionTimerHeap sessionKeyValueMap K.nil sessionCount
4327 ejectLoop sessionTimerHeap sessionKeyValueMap K.nil sessionCount
4328 return $ session
4328 return $ session
@@ -4339,14 +4339,14 @@ classifySessionsBy tick timeout reset ejectPred
4339 let hres = H.uncons hp
4339 let hres = H.uncons hp
4340 case hres of
4340 case hres of
4341 Just (Entry expiry key, hp1) -> do
4341 Just (Entry expiry key, hp1) -> do
4342− (eject, force) <- do
4342+ (eject, force) <-
4343 if curTime >= expiry
4343 if curTime >= expiry
4344 then return (True, False)
4344 then return (True, False)
4346 r <- ejectPred cnt
4346 r <- ejectPred cnt
4347 return (r, r)
4347 return (r, r)
4348 if eject
4348 if eject
4350 case Map.lookup key mp of
4350 case Map.lookup key mp of
4351 Nothing -> ejectLoop hp1 mp out cnt
4351 Nothing -> ejectLoop hp1 mp out cnt
4352 Just (Tuple' latestTS acc) -> do
4352 Just (Tuple' latestTS acc) -> do
@@ -4392,8 +4392,8 @@ classifyKeepAliveSessions
4392 -> Fold m a (Either b b) -- ^ Fold to be applied to session payload data
4392 -> Fold m a (Either b b) -- ^ Fold to be applied to session payload data
4393 -> t m (k, a, AbsTime) -- ^ session key, data, timestamp
4393 -> t m (k, a, AbsTime) -- ^ session key, data, timestamp
4394 -> t m (k, b)
4394 -> t m (k, b)
4395−classifyKeepAliveSessions timeout ejectPred =
4395+classifyKeepAliveSessions timeout =
4396− classifySessionsBy 1 timeout True ejectPred
4396+ classifySessionsBy 1 timeout True
4398------------------------------------------------------------------------------
4398------------------------------------------------------------------------------
4399-- Keyed tumbling windows
4399-- Keyed tumbling windows
@@ -4450,8 +4450,8 @@ classifySessionsOf
4450 -> Fold m a (Either b b) -- ^ Fold to be applied to session events
4450 -> Fold m a (Either b b) -- ^ Fold to be applied to session events
4451 -> t m (k, a, AbsTime) -- ^ session key, data, timestamp
4451 -> t m (k, a, AbsTime) -- ^ session key, data, timestamp
4452 -> t m (k, b)
4452 -> t m (k, b)
4453−classifySessionsOf interval ejectPred =
4453+classifySessionsOf interval =
4454− classifySessionsBy 1 interval False ejectPred
4454+ classifySessionsBy 1 interval False
4456------------------------------------------------------------------------------
4456------------------------------------------------------------------------------
4457-- Exceptions
4457-- Exceptions
@@ -4526,7 +4526,7 @@ finallyIO action xs = D.fromStreamD $ D.finallyIO action $ D.toStreamD xs
4526bracket :: (IsStream t, MonadCatch m)
4526bracket :: (IsStream t, MonadCatch m)
4527 => m b -> (b -> m c) -> (b -> t m a) -> t m a
4527 => m b -> (b -> m c) -> (b -> t m a) -> t m a
4528bracket bef aft bet = D.fromStreamD $
4528bracket bef aft bet = D.fromStreamD $
4529− D.bracket bef aft (\x -> toStreamD $ bet x)
4529+ D.bracket bef aft (toStreamD . bet)
4531-- | Run the first action before the stream starts and remember its output,
4531-- | Run the first action before the stream starts and remember its output,
4532-- generate a stream using the output, run the second action using the
4532-- generate a stream using the output, run the second action using the
@@ -4539,7 +4539,7 @@ bracket bef aft bet = D.fromStreamD $
4539bracketIO :: (IsStream t, MonadAsync m, MonadCatch m)
4539bracketIO :: (IsStream t, MonadAsync m, MonadCatch m)
4540 => m b -> (b -> m c) -> (b -> t m a) -> t m a
4540 => m b -> (b -> m c) -> (b -> t m a) -> t m a
4541bracketIO bef aft bet = D.fromStreamD $
4541bracketIO bef aft bet = D.fromStreamD $
4542− D.bracketIO bef aft (\x -> toStreamD $ bet x)
4542+ D.bracketIO bef aft (toStreamD . bet)
4544-- | When evaluating a stream if an exception occurs, stream evaluation aborts
4544-- | When evaluating a stream if an exception occurs, stream evaluation aborts
4545-- and the specified exception handler is run with the exception as argument.
4545-- and the specified exception handler is run with the exception as argument.
@@ -4549,7 +4549,7 @@ bracketIO bef aft bet = D.fromStreamD $
4549handle :: (IsStream t, MonadCatch m, Exception e)
4549handle :: (IsStream t, MonadCatch m, Exception e)
4550 => (e -> t m a) -> t m a -> t m a
4550 => (e -> t m a) -> t m a -> t m a
4551handle handler xs =
4551handle handler xs =
4552− D.fromStreamD $ D.handle (\e -> D.toStreamD $ handler e) $ D.toStreamD xs
4552+ D.fromStreamD $ D.handle (D.toStreamD . handler) $ D.toStreamD xs
4554------------------------------------------------------------------------------
4554------------------------------------------------------------------------------
4555-- Generalize the underlying monad
4555-- Generalize the underlying monad