on master help sign in
Cleanup hlint warnings
c9eff7eSanchayan Maity
src/Streamly/Internal/Data/Array.hs+6−6
@@ -77,11 +77,11 @@ toStreamD arr = D.Stream step 0
77 step _ (I# i) =
77 step _ (I# i) =
78 return $
78 return $
79 case Exts.indexArray# (array# arr) i of
79 case Exts.indexArray# (array# arr) i of
80− (# x #) -> D.Yield x ((I# i) + 1)
80+ (# x #) -> D.Yield x (I# i + 1)
81
81
82{-# INLINE length #-}
82{-# INLINE length #-}
83length :: Array a -> Int
83length :: Array a -> Int
84−length arr = sizeofArray arr
84+length = sizeofArray
85
85
86{-# INLINE_NORMAL toStreamDRev #-}
86{-# INLINE_NORMAL toStreamDRev #-}
87toStreamDRev :: Monad m => Array a -> D.Stream m a
87toStreamDRev :: Monad m => Array a -> D.Stream m a
@@ -93,7 +93,7 @@ toStreamDRev arr = D.Stream step (length arr - 1)
93 step _ (I# i) =
93 step _ (I# i) =
94 return $
94 return $
95 case Exts.indexArray# (array# arr) i of
95 case Exts.indexArray# (array# arr) i of
96− (# x #) -> D.Yield x ((I# i) - 1)
96+ (# x #) -> D.Yield x (I# i - 1)
97
97
98{-# INLINE_NORMAL foldl' #-}
98{-# INLINE_NORMAL foldl' #-}
99foldl' :: (b -> a -> b) -> b -> Array a -> b
99foldl' :: (b -> a -> b) -> b -> Array a -> b
@@ -143,14 +143,14 @@ fromStreamDN limit str = do
143 marr <- liftIO $ newArray (max limit 0) bottomElement
143 marr <- liftIO $ newArray (max limit 0) bottomElement
144 i <-
144 i <-
145 D.foldlM'
145 D.foldlM'
146− (\i x -> i `seq` (liftIO $ writeArray marr i x) >> return (i + 1))
146+ (\i x -> i `seq` liftIO $ writeArray marr i x >> return (i + 1))
147 0 $
147 0 $
148 D.take limit str
148 D.take limit str
149 liftIO $ freezeArray marr 0 i
149 liftIO $ freezeArray marr 0 i
150
150
151{-# INLINE fromStreamD #-}
151{-# INLINE fromStreamD #-}
152fromStreamD :: MonadIO m => D.Stream m a -> m (Array a)
152fromStreamD :: MonadIO m => D.Stream m a -> m (Array a)
153−fromStreamD str = D.runFold write str
153+fromStreamD = D.runFold write
154
154
155{-# INLINABLE fromListN #-}
155{-# INLINABLE fromListN #-}
156fromListN :: Int -> [a] -> Array a
156fromListN :: Int -> [a] -> Array a
@@ -197,7 +197,7 @@ read = Unfold step inject
197 inject arr = return (arr, 0)
197 inject arr = return (arr, 0)
198 step (arr, i)
198 step (arr, i)
199 | i == length arr = return D.Stop
199 | i == length arr = return D.Stop
200− step (arr, (I# i)) =
200+ step (arr, I# i) =
201 return $
201 return $
202 case Exts.indexArray# (array# arr) i of
202 case Exts.indexArray# (array# arr) i of
203 (# x #) -> D.Yield x (arr, I# i + 1)
203 (# x #) -> D.Yield x (arr, I# i + 1)
src/Streamly/Internal/Data/Fold.hs+8−11
@@ -3,7 +3,6 @@
3{-# LANGUAGE ExistentialQuantification #-}
3{-# LANGUAGE ExistentialQuantification #-}
4{-# LANGUAGE FlexibleContexts #-}
4{-# LANGUAGE FlexibleContexts #-}
5{-# LANGUAGE RankNTypes #-}
5{-# LANGUAGE RankNTypes #-}
6−{-# LANGUAGE RecordWildCards #-}
7{-# LANGUAGE ScopedTypeVariables #-}
6{-# LANGUAGE ScopedTypeVariables #-}
8
7
9-- |
8-- |
@@ -209,7 +208,7 @@ module Streamly.Internal.Data.Fold
209 )
208 )
210where
209where
211
210
212−import Control.Monad (void)
211+import Control.Monad (join, void)
213import Control.Monad.IO.Class (MonadIO(..))
212import Control.Monad.IO.Class (MonadIO(..))
214import Data.Functor.Identity (Identity(..))
213import Data.Functor.Identity (Identity(..))
215import Data.Int (Int64)
214import Data.Int (Int64)
@@ -308,9 +307,7 @@ generally = hoist (return . runIdentity)
308sequence :: Monad m => Fold m a (m b) -> Fold m a b
307sequence :: Monad m => Fold m a (m b) -> Fold m a b
309sequence (Fold step initial extract) = Fold step initial extract'
308sequence (Fold step initial extract) = Fold step initial extract'
310 where
309 where
311− extract' x = do
310+ extract' x = join (extract x)
312− act <- extract x
313− act >>= return
314
311
315-- | Map a monadic function on the output of a fold.
312-- | Map a monadic function on the output of a fold.
316--
313--
@@ -937,7 +934,7 @@ splitAt n (Fold stepL initialL extractL) (Fold stepR initialR extractR) =
937 step (Tuple3' i xL xR) input =
934 step (Tuple3' i xL xR) input =
938 if i > 0
935 if i > 0
939 then stepL xL input >>= (\a -> return (Tuple3' (i - 1) a xR))
936 then stepL xL input >>= (\a -> return (Tuple3' (i - 1) a xR))
940− else stepR xR input >>= (\b -> return (Tuple3' i xL b))
937+ else stepR xR input >>= (return . Tuple3' i xL)
941
938
942 extract (Tuple3' _ a b) = (,) <$> extractL a <*> extractR b
939 extract (Tuple3' _ a b) = (,) <$> extractL a <*> extractR b
943
940
@@ -1135,7 +1132,7 @@ foldCons (Fold stepL beginL doneL) (Fold stepR beginR doneR) =
1135
1132
1136 begin = Tuple' <$> beginL <*> beginR
1133 begin = Tuple' <$> beginL <*> beginR
1137 step (Tuple' xL xR) a = Tuple' <$> stepL xL a <*> stepR xR a
1134 step (Tuple' xL xR) a = Tuple' <$> stepL xL a <*> stepR xR a
1138− done (Tuple' xL xR) = (:) <$> (doneL xL) <*> (doneR xR)
1135+ done (Tuple' xL xR) = (:) <$> doneL xL <*> doneR xR
1139
1136
1140-- XXX use "List" instead of "[]"?, use Array for output to scale it to a large
1137-- XXX use "List" instead of "[]"?, use Array for output to scale it to a large
1141-- number of consumers? For polymorphic case a vector could be helpful. For
1138-- number of consumers? For polymorphic case a vector could be helpful. For
@@ -1174,7 +1171,7 @@ distribute_ fs = Fold step initial extract
1174 initial = Prelude.mapM (\(Fold s i e) ->
1171 initial = Prelude.mapM (\(Fold s i e) ->
1175 i >>= \r -> return (Fold s (return r) e)) fs
1172 i >>= \r -> return (Fold s (return r) e)) fs
1176 step ss a = do
1173 step ss a = do
1177− Prelude.mapM_ (\(Fold s i _) -> i >>= \r -> s r a >> return ()) ss
1174+ Prelude.mapM_ (\(Fold s i _) -> i >>= \r -> void (s r a)) ss
1178 return ss
1175 return ss
1179 extract ss = do
1176 extract ss = do
1180 Prelude.mapM_ (\(Fold _ i e) -> i >>= \r -> e r) ss
1177 Prelude.mapM_ (\(Fold _ i e) -> i >>= \r -> e r) ss
@@ -1413,7 +1410,7 @@ demuxWith_ f kv = Fold step initial extract
1413
1410
1414 where
1411 where
1415
1412
1416− initial = do
1413+ initial =
1417 Prelude.mapM (\(Fold s i e) ->
1414 Prelude.mapM (\(Fold s i e) ->
1418 i >>= \r -> return (Fold s (return r) e)) kv
1415 i >>= \r -> return (Fold s (return r) e)) kv
1419 step mp a
1416 step mp a
@@ -1426,7 +1423,7 @@ demuxWith_ f kv = Fold step initial extract
1426 Just (Fold step' acc _) -> do
1423 Just (Fold step' acc _) -> do
1427 _ <- acc >>= \x -> step' x a'
1424 _ <- acc >>= \x -> step' x a'
1428 return mp
1425 return mp
1429− extract mp = Prelude.mapM_ (\(Fold _ acc e) -> acc >>= e) mp
1426+ extract = Prelude.mapM_ (\(Fold _ acc e) -> acc >>= e)
1430
1427
1431-- | Given a stream of key value pairs and a map from keys to folds, fold the
1428-- | Given a stream of key value pairs and a map from keys to folds, fold the
1432-- values for each key using the corresponding folds, discarding the outputs.
1429-- values for each key using the corresponding folds, discarding the outputs.
@@ -1622,7 +1619,7 @@ toParallelSVar svar winfo = Fold step initial extract
1622 decrementBufferLimit svar
1619 decrementBufferLimit svar
1623 void $ send svar (ChildYield x)
1620 void $ send svar (ChildYield x)
1624
1621
1625− extract () = liftIO $ do
1622+ extract () = liftIO $
1626 sendStop svar winfo
1623 sendStop svar winfo
1627
1624
1628{-# INLINE toParallelSVarLimited #-}
1625{-# INLINE toParallelSVarLimited #-}
src/Streamly/Internal/Data/Fold/Types.hs+9−9
@@ -403,7 +403,7 @@ ltake :: Monad m => Int -> Fold m a b -> Fold m a b
403ltake n (Fold step initial done) = Fold step' initial' done'
403ltake n (Fold step initial done) = Fold step' initial' done'
404 where
404 where
405 initial' = fmap (Tuple' 0) initial
405 initial' = fmap (Tuple' 0) initial
406− step' (Tuple' i r) a = do
406+ step' (Tuple' i r) a =
407 if i < n
407 if i < n
408 then do
408 then do
409 res <- step r a
409 res <- step r a
@@ -419,9 +419,9 @@ ltakeWhile :: Monad m => (a -> Bool) -> Fold m a b -> Fold m a b
419ltakeWhile predicate (Fold step initial done) = Fold step' initial' done'
419ltakeWhile predicate (Fold step initial done) = Fold step' initial' done'
420 where
420 where
421 initial' = fmap Left' initial
421 initial' = fmap Left' initial
422− step' (Left' r) a = do
422+ step' (Left' r) a =
423 if predicate a
423 if predicate a
424− then fmap Left' $ step r a
424+ then Left' <$> step r a
425 else return (Right' r)
425 else return (Right' r)
426 step' r _ = return r
426 step' r _ = return r
427 done' (Left' r) = done r
427 done' (Left' r) = done r
@@ -464,7 +464,7 @@ runStep :: Monad m => Fold m a b -> a -> m (Fold m a b)
464runStep (Fold step initial extract) a = do
464runStep (Fold step initial extract) a = do
465 i <- initial
465 i <- initial
466 r <- step i a
466 r <- step i a
467− return $ (Fold step (return r) extract)
467+ return $ Fold step (return r) extract
468
468
469------------------------------------------------------------------------------
469------------------------------------------------------------------------------
470-- Parsing
470-- Parsing
@@ -483,8 +483,8 @@ lchunksOf n (Fold step1 initial1 extract1) (Fold step2 initial2 extract2) =
483
483
484 where
484 where
485
485
486− initial' = (Tuple3' 0) <$> initial1 <*> initial2
486+ initial' = Tuple3' 0 <$> initial1 <*> initial2
487− step' (Tuple3' i r1 r2) a = do
487+ step' (Tuple3' i r1 r2) a =
488 if i < n
488 if i < n
489 then do
489 then do
490 res <- step1 r1 a
490 res <- step1 r1 a
@@ -508,8 +508,8 @@ lchunksOf2 n (Fold step1 initial1 extract1) (Fold2 step2 inject2 extract2) =
508
508
509 where
509 where
510
510
511− inject' x = (Tuple3' 0) <$> initial1 <*> inject2 x
511+ inject' x = Tuple3' 0 <$> initial1 <*> inject2 x
512− step' (Tuple3' i r1 r2) a = do
512+ step' (Tuple3' i r1 r2) a =
513 if i < n
513 if i < n
514 then do
514 then do
515 res <- step1 r1 a
515 res <- step1 r1 a
@@ -580,7 +580,7 @@ lsessionsOf n (Fold step1 initial1 extract1) (Fold step2 initial2 extract2) =
580 r2 <- liftIO $ takeMVar mv2
580 r2 <- liftIO $ takeMVar mv2
581 res <- case r2 of
581 res <- case r2 of
582 Left _ -> return r2
582 Left _ -> return r2
583− Right x -> fmap Right $ step2 x res1
583+ Right x -> Right <$> step2 x res1
584 liftIO $ putMVar mv2 res
584 liftIO $ putMVar mv2 res
585 timerThread mv1 mv2
585 timerThread mv1 mv2
586
586
src/Streamly/Internal/Prelude.hs+22−22
@@ -1579,7 +1579,7 @@ isPrefixOf m1 m2 = D.isPrefixOf (toStreamD m1) (toStreamD m2)
1579--
1579--
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
1583
1583
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
1757 where
1757 where
1758 go m1 =
1758 go m1 =
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
3027 where
3027 where
3028 go x = yield x `combine` concatMapWith combine go (f x)
3028 go x = yield x `combine` concatMapWith combine go (f x)
3029
3029
@@ -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
3062 where
3062 where
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
3963
3963
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
3989
3989
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
4191
4191
4192 where
4192 where
@@ -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.
4214
4214
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
4218 -- size
4218 -- size
4219 --
4219 --
@@ -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
4279
4279
@@ -4288,7 +4288,7 @@ classifySessionsBy tick timeout reset ejectPred
4288 }
4288 }
4289
4289
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
4294
4294
@@ -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)
4306
4306
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)
4324
4324
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)
4345 else do
4345 else do
4346 r <- ejectPred cnt
4346 r <- ejectPred cnt
4347 return (r, r)
4347 return (r, r)
4348 if eject
4348 if eject
4349− then do
4349+ then
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
4397
4397
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
4455
4455
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)
4530
4530
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)
4543
4543
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
4553
4553
4554------------------------------------------------------------------------------
4554------------------------------------------------------------------------------
4555-- Generalize the underlying monad
4555-- Generalize the underlying monad