on master help sign in
Cleanup hlint warnings
commitbc39dfea9d39c8e47e305a690a9ade06d36316dd authorSanchayan Maity <sanchayan@sanchayanmaity.net> dateSat 11 Sep 2021, 17:28 (5 years ago) parent932f7b2
14 files changed+85−105
.hlint.ignore−18 src/Streamly/Internal/Data/Stream/Ahead.hs+2−2 src/Streamly/Internal/Data/Stream/Async.hs+6−6 src/Streamly/Internal/Data/Stream/Parallel.hs+4−4 src/Streamly/Internal/Data/Stream/StreamD/Eliminate.hs+7−7 src/Streamly/Internal/Data/Stream/StreamD/Exception.hs+6−6 src/Streamly/Internal/Data/Stream/StreamD/Generate.hs+1−1 src/Streamly/Internal/Data/Stream/StreamD/Lift.hs+1−1 src/Streamly/Internal/Data/Stream/StreamD/Nesting.hs+6−6 src/Streamly/Internal/Data/Stream/StreamD/Transform.hs+8−8 src/Streamly/Internal/Data/Stream/StreamDK.hs+1−1 src/Streamly/Internal/Data/Stream/StreamDK/Type.hs+1−1 src/Streamly/Internal/Data/Stream/StreamK.hs+28−30 src/Streamly/Internal/Data/Stream/StreamK/Type.hs+14−14
.hlint.ignore−18
@@ -1,30 +1,12 @@
1−src/Streamly/Internal/Data/Stream/SVar.hs
21src/Streamly/Internal/Data/Stream/Serial.hs
32src/Streamly/Internal/Data/Stream/Zip.hs
4−src/Streamly/Internal/Data/Stream/Parallel.hs
5−src/Streamly/Internal/Data/Stream/Async.hs
6−src/Streamly/Internal/Data/Stream/StreamDK.hs
7−src/Streamly/Internal/Data/Stream/StreamK.hs
83src/Streamly/Internal/Data/Stream/StreamK/Type.hs
9−src/Streamly/Internal/Data/Stream/Ahead.hs
104src/Streamly/Internal/Data/Stream/StreamD/Type.hs
11−src/Streamly/Internal/Data/Stream/StreamDK/Type.hs
12−src/Streamly/Internal/Data/Stream/StreamD.hs
13−src/Streamly/Internal/Data/Stream/StreamD/Generate.hs
14−src/Streamly/Internal/Data/Stream/StreamD/Eliminate.hs
15−src/Streamly/Internal/Data/Stream/StreamD/Transform.hs
16−src/Streamly/Internal/Data/Stream/StreamD/Exception.hs
17−src/Streamly/Internal/Data/Stream/StreamD/Lift.hs
18−src/Streamly/Internal/Data/Stream/StreamD/Nesting.hs
195src/Streamly/Internal/Data/Pipe/Type.hs
206src/Streamly/Internal/Data/SmallArray/Type.hs
217src/Streamly/Internal/Unicode/Stream.hs
22−src/Streamly/Internal/Data/IORef/Prim.hs
238src/Streamly/Internal/Data/Array/Prim/Type.hs
24−src/Streamly/Internal/Data/Array/Prim/Mut/Type.hs
259src/Streamly/Internal/Data/Array/Prim/MutTypesInclude.hs
26−src/Streamly/Internal/Data/Array/Prim/Pinned/Mut/Type.hs
27−src/Streamly/Internal/Data/Array/Prim/Pinned/Type.hs
2810src/Streamly/Internal/Data/Array/Prim/TypesInclude.hs
2911test/Streamly/Test/Common/Array.hs
3012test/Streamly/Test/Data/Array.hs
src/Streamly/Internal/Data/Stream/Ahead.hs+2−2
@@ -677,7 +677,7 @@ ahead m1 m2 = mkStream $ \st yld sng stp ->
677677{-# INLINE consMAhead #-}
678678{-# SPECIALIZE consMAhead :: IO a -> AheadT IO a -> AheadT IO a #-}
679679consMAhead :: MonadAsync m => m a -> AheadT m a -> AheadT m a
680−consMAhead m r = fromStream $ K.fromEffect m `ahead` (toStream r)
680+consMAhead m r = fromStream $ K.fromEffect m `ahead` toStream r
681681
682682------------------------------------------------------------------------------
683683-- AheadT
@@ -779,7 +779,7 @@ instance MonadAsync m => Monoid (AheadT m a) where
779779{-# SPECIALIZE concatMapAhead :: (a -> AheadT IO b) -> AheadT IO a -> AheadT IO b #-}
780780concatMapAhead :: MonadAsync m => (a -> AheadT m b) -> AheadT m a -> AheadT m b
781781concatMapAhead f m = fromStream $
782− K.concatMapBy ahead (\a -> K.adapt $ f a) (K.adapt m)
782+ K.concatMapBy ahead (K.adapt . f) (K.adapt m)
783783
784784{-# INLINE apAhead #-}
785785apAhead :: MonadAsync m => AheadT m (a -> b) -> AheadT m a -> AheadT m b
src/Streamly/Internal/Data/Stream/Async.hs+6−6
@@ -667,7 +667,7 @@ forkSVarAsync style m1 m2 = mkStream $ \st yld sng stp -> do
667667 where
668668 concurrently ma mb = mkStream $ \st yld sng stp -> do
669669 runInIO <- captureMonadState
670− liftIO $ enqueue (fromJust $ streamVar st) $ (runInIO, mb)
670+ liftIO $ enqueue (fromJust $ streamVar st) (runInIO, mb)
671671 foldStreamShared st yld sng stp ma
672672
673673{-# INLINE joinStreamVarAsync #-}
@@ -677,7 +677,7 @@ joinStreamVarAsync style m1 m2 = mkStream $ \st yld sng stp ->
677677 case streamVar st of
678678 Just sv | svarStyle sv == style -> do
679679 runInIO <- captureMonadState
680− liftIO $ enqueue sv $ (runInIO, toStream m2)
680+ liftIO $ enqueue sv (runInIO, toStream m2)
681681 foldStreamShared st yld sng stp m1
682682 _ -> foldStreamShared st yld sng stp (forkSVarAsync style m1 m2)
683683
@@ -769,7 +769,7 @@ async = joinStreamVarAsync AsyncVar
769769{-# INLINE consMAsync #-}
770770{-# SPECIALIZE consMAsync :: IO a -> AsyncT IO a -> AsyncT IO a #-}
771771consMAsync :: MonadAsync m => m a -> AsyncT m a -> AsyncT m a
772−consMAsync m r = fromStream $ K.fromEffect m `async` (toStream r)
772+consMAsync m r = fromStream $ K.fromEffect m `async` toStream r
773773
774774------------------------------------------------------------------------------
775775-- AsyncT
@@ -891,7 +891,7 @@ instance (Monad m, MonadAsync m) => Applicative (AsyncT m) where
891891{-# INLINE bindAsync #-}
892892{-# SPECIALIZE bindAsync :: AsyncT IO a -> (a -> AsyncT IO b) -> AsyncT IO b #-}
893893bindAsync :: MonadAsync m => AsyncT m a -> (a -> AsyncT m b) -> AsyncT m b
894−bindAsync m f = fromStream $ K.bindWith async (adapt m) (\a -> adapt $ f a)
894+bindAsync m f = fromStream $ K.bindWith async (adapt m) (adapt . f)
895895
896896-- GHC: if we specify arguments in the definition of (>>=) we see a significant
897897-- performance degradation (~2x).
@@ -914,7 +914,7 @@ MONAD_COMMON_INSTANCES(AsyncT, MONADPARALLEL)
914914{-# INLINE consMWAsync #-}
915915{-# SPECIALIZE consMWAsync :: IO a -> WAsyncT IO a -> WAsyncT IO a #-}
916916consMWAsync :: MonadAsync m => m a -> WAsyncT m a -> WAsyncT m a
917−consMWAsync m r = fromStream $ K.fromEffect m `wAsync` (toStream r)
917+consMWAsync m r = fromStream $ K.fromEffect m `wAsync` toStream r
918918
919919infixr 6 `wAsync`
920920
@@ -1192,7 +1192,7 @@ instance (Monad m, MonadAsync m) => Applicative (WAsyncT m) where
11921192{-# INLINE bindWAsync #-}
11931193{-# SPECIALIZE bindWAsync :: WAsyncT IO a -> (a -> WAsyncT IO b) -> WAsyncT IO b #-}
11941194bindWAsync :: MonadAsync m => WAsyncT m a -> (a -> WAsyncT m b) -> WAsyncT m b
1195−bindWAsync m f = fromStream $ K.bindWith wAsync (adapt m) (\a -> adapt $ f a)
1195+bindWAsync m f = fromStream $ K.bindWith wAsync (adapt m) (adapt . f)
11961196
11971197-- GHC: if we specify arguments in the definition of (>>=) we see a significant
11981198-- performance degradation (~2x).
src/Streamly/Internal/Data/Stream/Parallel.hs+4−4
@@ -124,7 +124,7 @@ runOne st m0 winfo =
124124 incrementBufferLimit sv
125125 sendStop sv winfo
126126 sendit a = liftIO $ void $ send sv (ChildYield a)
127− single a = sendit a >> (liftIO $ sendStop sv winfo)
127+ single a = sendit a >> liftIO (sendStop sv winfo)
128128 yieldk a r = sendit a >> go r
129129
130130runOneLimited
@@ -151,7 +151,7 @@ runOneLimited st m0 winfo = go m0
151151 incrementYieldLimit sv
152152 sendStop sv winfo
153153 sendit a = liftIO $ void $ send sv (ChildYield a)
154− single a = sendit a >> (liftIO $ sendStop sv winfo)
154+ single a = sendit a >> liftIO (sendStop sv winfo)
155155 yieldk a r = sendit a >> go r
156156
157157-------------------------------------------------------------------------------
@@ -234,7 +234,7 @@ joinStreamVarPar style ss m1 m2 = mkStream $ \st yld sng stp ->
234234{-# INLINE consMParallel #-}
235235{-# SPECIALIZE consMParallel :: IO a -> ParallelT IO a -> ParallelT IO a #-}
236236consMParallel :: MonadAsync m => m a -> ParallelT m a -> ParallelT m a
237−consMParallel m r = fromStream $ K.fromEffect m `parallel` (toStream r)
237+consMParallel m r = fromStream $ K.fromEffect m `parallel` toStream r
238238
239239infixr 6 `parallel`
240240
@@ -568,7 +568,7 @@ instance (Monad m, MonadAsync m) => Applicative (ParallelT m) where
568568{-# INLINE bindParallel #-}
569569{-# SPECIALIZE bindParallel :: ParallelT IO a -> (a -> ParallelT IO b) -> ParallelT IO b #-}
570570bindParallel :: MonadAsync m => ParallelT m a -> (a -> ParallelT m b) -> ParallelT m b
571−bindParallel m f = fromStream $ K.bindWith parallel (K.adapt m) (\a -> K.adapt $ f a)
571+bindParallel m f = fromStream $ K.bindWith parallel (K.adapt m) (K.adapt . f)
572572
573573instance MonadAsync m => Monad (ParallelT m) where
574574 return = pure
src/Streamly/Internal/Data/Stream/StreamD/Eliminate.hs+7−7
@@ -243,15 +243,15 @@ drain (Stream step state) = go SPEC state
243243
244244{-# INLINE_NORMAL null #-}
245245null :: Monad m => Stream m a -> m Bool
246−null m = foldrM (\_ _ -> return False) (return True) m
246+null = foldrM (\_ _ -> return False) (return True)
247247
248248{-# INLINE_NORMAL head #-}
249249head :: Monad m => Stream m a -> m (Maybe a)
250−head m = foldrM (\x _ -> return (Just x)) (return Nothing) m
250+head = foldrM (\x _ -> return (Just x)) (return Nothing)
251251
252252{-# INLINE_NORMAL headElse #-}
253253headElse :: Monad m => a -> Stream m a -> m a
254−headElse a m = foldrM (\x _ -> return x) (return a) m
254+headElse a = foldrM (\x _ -> return x) (return a)
255255
256256-- Does not fuse, has the same performance as the StreamK version.
257257{-# INLINE_NORMAL tail #-}
@@ -407,13 +407,13 @@ minimumBy cmp (Stream step state) = go Nothing state
407407
408408{-# INLINE_NORMAL lookup #-}
409409lookup :: (Monad m, Eq a) => a -> Stream m (a, b) -> m (Maybe b)
410−lookup e m = foldrM (\(a, b) xs -> if e == a then return (Just b) else xs)
411− (return Nothing) m
410+lookup e = foldrM (\(a, b) xs -> if e == a then return (Just b) else xs)
411+ (return Nothing)
412412
413413{-# INLINE_NORMAL findM #-}
414414findM :: Monad m => (a -> m Bool) -> Stream m a -> m (Maybe a)
415−findM p m = foldrM (\x xs -> p x >>= \r -> if r then return (Just x) else xs)
416− (return Nothing) m
415+findM p = foldrM (\x xs -> p x >>= \r -> if r then return (Just x) else xs)
416+ (return Nothing)
417417
418418{-# INLINE find #-}
419419find :: Monad m => (a -> Bool) -> Stream m a -> m (Maybe a)
src/Streamly/Internal/Data/Stream/StreamD/Exception.hs+6−6
@@ -239,7 +239,7 @@ onException :: MonadCatch m => m b -> Stream m a -> Stream m a
239239onException action str =
240240 gbracket_ (return ()) (inline MC.try) return
241241 (\_ (e :: MC.SomeException) _ -> nilM (action >> MC.throwM e))
242− (\_ -> str)
242+ (const str)
243243
244244{-# INLINE_NORMAL _onException #-}
245245_onException :: MonadCatch m => m b -> Stream m a -> Stream m a
@@ -260,9 +260,9 @@ _onException action (Stream step state) = Stream step' state
260260{-# INLINE_NORMAL bracket_ #-}
261261bracket_ :: MonadCatch m
262262 => m b -> (b -> m c) -> (b -> Stream m a) -> Stream m a
263−bracket_ bef aft bet =
263+bracket_ bef aft =
264264 gbracket_ bef (inline MC.try) aft
265− (\a (e :: SomeException) _ -> nilM (aft a >> MC.throwM e)) bet
265+ (\a (e :: SomeException) _ -> nilM (aft a >> MC.throwM e))
266266
267267-- | See 'Streamly.Internal.Data.Stream.IsStream.bracket'.
268268--
@@ -308,7 +308,7 @@ _bracket bef aft bet = Stream step' BracketInit
308308--
309309{-# INLINE finally_ #-}
310310finally_ :: MonadCatch m => m b -> Stream m a -> Stream m a
311−finally_ action xs = bracket_ (return ()) (\_ -> action) (const xs)
311+finally_ action xs = bracket_ (return ()) (const action) (const xs)
312312
313313-- | See 'Streamly.Internal.Data.Stream.IsStream.finally'.
314314--
@@ -325,7 +325,7 @@ finally action xs = bracket' (return ()) act act act (const xs)
325325ghandle :: (MonadCatch m, Exception e)
326326 => (e -> Stream m a -> Stream m a) -> Stream m a -> Stream m a
327327ghandle f str =
328− gbracket_ (return ()) (inline MC.try) return (\_ -> f) (\_ -> str)
328+ gbracket_ (return ()) (inline MC.try) return (const f) (const str)
329329
330330-- | See 'Streamly.Internal.Data.Stream.IsStream.handle'.
331331--
@@ -333,7 +333,7 @@ ghandle f str =
333333handle :: (MonadCatch m, Exception e)
334334 => (e -> Stream m a) -> Stream m a -> Stream m a
335335handle f str =
336− gbracket_ (return ()) (inline MC.try) return (\_ e _ -> f e) (\_ -> str)
336+ gbracket_ (return ()) (inline MC.try) return (\_ e _ -> f e) (const str)
337337
338338-- | Alternate (custom) implementation of 'handle'.
339339--
src/Streamly/Internal/Data/Stream/StreamD/Generate.hs+1−1
@@ -133,7 +133,7 @@ cons x (Stream step state) = Stream step1 Nothing
133133-- Adapted from vector package
134134{-# INLINE_NORMAL unfoldrM #-}
135135unfoldrM :: Monad m => (s -> m (Maybe (a, s))) -> s -> Stream m a
136−unfoldrM next state = Stream step state
136+unfoldrM next = Stream step
137137 where
138138 {-# INLINE_LATE step #-}
139139 step _ st = do
src/Streamly/Internal/Data/Stream/StreamD/Lift.hs+1−1
@@ -41,7 +41,7 @@ import Streamly.Internal.Data.Stream.StreamD.Type
4141
4242{-# INLINE_NORMAL hoist #-}
4343hoist :: Monad n => (forall x. m x -> n x) -> Stream m a -> Stream n a
44−hoist f (Stream step state) = (Stream step' state)
44+hoist f (Stream step state) = Stream step' state
4545 where
4646 {-# INLINE_LATE step' #-}
4747 step' gst st = do
src/Streamly/Internal/Data/Stream/StreamD/Nesting.hs+6−6
@@ -2173,7 +2173,7 @@ splitOnSuffixSeq withSep patArr (Fold fstep initial done) (Stream step state) =
21732173 r <- if withSep then fstep fs x else fstep fs old
21742174 case r of
21752175 FL.Partial fs1 ->
2176− if (cksum1 /= patHash)
2176+ if cksum1 /= patHash
21772177 then go SPEC fs1 s rh1 cksum1
21782178 else skip $ SplitOnSuffixSeqKRCheck fs1 s rb rh1
21792179 FL.Done b -> do
@@ -2239,7 +2239,7 @@ splitInnerBy
22392239 -> Stream m (f a)
22402240 -> Stream m (f a)
22412241splitInnerBy splitter joiner (Stream step1 state1) =
2242− (Stream step (SplitInitial state1))
2242+ Stream step (SplitInitial state1)
22432243
22442244 where
22452245
@@ -2253,7 +2253,7 @@ splitInnerBy splitter joiner (Stream step1 state1) =
22532253 Nothing -> Skip (SplitBuffering s x1)
22542254 Just x2 -> Skip (SplitYielding x1 (SplitSplitting s x2))
22552255 Skip s -> return $ Skip (SplitInitial s)
2256− Stop -> return $ Stop
2256+ Stop -> return Stop
22572257
22582258 step gst (SplitBuffering st buf) = do
22592259 r <- step1 gst st
@@ -2274,7 +2274,7 @@ splitInnerBy splitter joiner (Stream step1 state1) =
22742274 Just x2 -> Skip $ SplitYielding x1 (SplitSplitting st x2)
22752275
22762276 step _ (SplitYielding x next) = return $ Yield x next
2277− step _ SplitFinishing = return $ Stop
2277+ step _ SplitFinishing = return Stop
22782278
22792279-- | Performs infix separator style splitting.
22802280{-# INLINE_NORMAL splitInnerBySuffix #-}
@@ -2285,7 +2285,7 @@ splitInnerBySuffix
22852285 -> Stream m (f a)
22862286 -> Stream m (f a)
22872287splitInnerBySuffix splitter joiner (Stream step1 state1) =
2288− (Stream step (SplitInitial state1))
2288+ Stream step (SplitInitial state1)
22892289
22902290 where
22912291
@@ -2299,7 +2299,7 @@ splitInnerBySuffix splitter joiner (Stream step1 state1) =
22992299 Nothing -> Skip (SplitBuffering s x1)
23002300 Just x2 -> Skip (SplitYielding x1 (SplitSplitting s x2))
23012301 Skip s -> return $ Skip (SplitInitial s)
2302− Stop -> return $ Stop
2302+ Stop -> return Stop
23032303
23042304 step gst (SplitBuffering st buf) = do
23052305 r <- step1 gst st
src/Streamly/Internal/Data/Stream/StreamD/Transform.hs+8−8
@@ -535,8 +535,8 @@ postscanlMx' fstep begin done (Stream step state) = do
535535{-# INLINE_NORMAL postscanlx' #-}
536536postscanlx' :: Monad m
537537 => (x -> a -> x) -> x -> (x -> b) -> Stream m a -> Stream m b
538−postscanlx' fstep begin done s =
539− postscanlMx' (\b a -> return (fstep b a)) (return begin) (return . done) s
538+postscanlx' fstep begin done =
539+ postscanlMx' (\b a -> return (fstep b a)) (return begin) (return . done)
540540
541541-- XXX do we need consM strict to evaluate the begin value?
542542{-# INLINE scanlMx' #-}
@@ -548,8 +548,8 @@ scanlMx' fstep begin done s =
548548{-# INLINE scanlx' #-}
549549scanlx' :: Monad m
550550 => (x -> a -> x) -> x -> (x -> b) -> Stream m a -> Stream m b
551−scanlx' fstep begin done s =
552− scanlMx' (\b a -> return (fstep b a)) (return begin) (return . done) s
551+scanlx' fstep begin done =
552+ scanlMx' (\b a -> return (fstep b a)) (return begin) (return . done)
553553
554554------------------------------------------------------------------------------
555555-- postscans
@@ -669,7 +669,7 @@ scanlM fstep begin (Stream step state) = Stream step' Nothing
669669 y <- fstep acc x
670670 return $ Yield y (Just (s, y))
671671 Skip s -> return $ Skip (Just (s, acc))
672− Stop -> return $ Stop
672+ Stop -> return Stop
673673
674674{-# INLINE scanl #-}
675675scanl :: Monad m => (b -> a -> b) -> b -> Stream m a -> Stream m b
@@ -1068,12 +1068,12 @@ intersperseSuffixBySpan n action (Stream step state) =
10681068 step' _ (SuffixSpanSuffix st) = do
10691069 action >>= \r -> return $ Skip (SuffixSpanYield r (SuffixSpanElem st n))
10701070
1071− step' _ (SuffixSpanLast) = do
1071+ step' _ SuffixSpanLast = do
10721072 action >>= \r -> return $ Skip (SuffixSpanYield r SuffixSpanStop)
10731073
10741074 step' _ (SuffixSpanYield x next) = return $ Yield x next
10751075
1076− step' _ (SuffixSpanStop) = return Stop
1076+ step' _ SuffixSpanStop = return Stop
10771077
10781078------------------------------------------------------------------------------
10791079-- Reordering
@@ -1208,7 +1208,7 @@ rollingMapM f (Stream step1 state1) = Stream step (RollingMapInit state1)
12081208 !res <- f x x1
12091209 return $ Yield res $ RollingMapGo s x
12101210 Skip s -> return $ Skip $ RollingMapGo s x1
1211− Stop -> return $ Stop
1211+ Stop -> return Stop
12121212
12131213{-# INLINE rollingMap #-}
12141214rollingMap :: Monad m => (a -> a -> b) -> Stream m a -> Stream m b
src/Streamly/Internal/Data/Stream/StreamDK.hs+1−1
@@ -112,7 +112,7 @@ foldrS f streamb = go
112112
113113{-# INLINE_LATE foldrM #-}
114114foldrM :: Monad m => (a -> m b -> m b) -> m b -> Stream m a -> m b
115−foldrM fstep acc ys = go ys
115+foldrM fstep acc = go
116116 where
117117 go (Stream step) = do
118118 r <- step
src/Streamly/Internal/Data/Stream/StreamDK/Type.hs+1−1
@@ -101,4 +101,4 @@ where
101101-- XXX Use Cons and Nil instead of Yield and Stop?
102102data Step m a = Yield a (Stream m a) | Stop
103103
104−data Stream m a = Stream (m (Step m a))
104+newtype Stream m a = Stream (m (Step m a))
src/Streamly/Internal/Data/Stream/StreamK.hs+28−30
@@ -314,7 +314,7 @@ fromIndicesM gen = go 0
314314fromIndices :: IsStream t => (Int -> a) -> t m a
315315fromIndices gen = go 0
316316 where
317− go n = (gen n) `cons` go (n + 1)
317+ go n = gen n `cons` go (n + 1)
318318
319319{-# INLINE iterate #-}
320320iterate :: IsStream t => (a -> a) -> a -> t m a
@@ -367,7 +367,7 @@ foldr step acc = foldrM (\x xs -> xs >>= \b -> return (step x b)) (return acc)
367367{-# INLINE foldrT #-}
368368foldrT :: (IsStream t, Monad m, Monad (s m), MonadTrans s)
369369 => (a -> s m b -> s m b) -> s m b -> t m a -> s m b
370−foldrT step final m = go m
370+foldrT step final = go
371371 where
372372 go m1 = do
373373 res <- lift $ uncons m1
@@ -394,7 +394,7 @@ foldr1 step m = do
394394{-# INLINABLE foldlMx' #-}
395395foldlMx' :: (IsStream t, Monad m)
396396 => (x -> a -> m x) -> m x -> (x -> m b) -> t m a -> m b
397−foldlMx' step begin done m = go begin m
397+foldlMx' step begin done = go begin
398398 where
399399 go !acc m1 =
400400 let stop = acc >>= done
@@ -431,7 +431,7 @@ foldlM' step begin = foldlMx' step begin return
431431-- | Lazy left fold to a stream.
432432{-# INLINE foldlS #-}
433433foldlS :: IsStream t => (t m b -> a -> t m b) -> t m b -> t m a -> t m b
434−foldlS step begin m = go begin m
434+foldlS step = go
435435 where
436436 go acc rest = mkStream $ \st yld sng stp ->
437437 let run x = foldStream st yld sng stp x
@@ -444,7 +444,7 @@ foldlS step begin m = go begin m
444444{-# INLINE foldlT #-}
445445foldlT :: (IsStream t, Monad m, Monad (s m), MonadTrans s)
446446 => (s m b -> a -> s m b) -> s m b -> t m a -> s m b
447−foldlT step begin m = go begin m
447+foldlT step = go
448448 where
449449 go acc m1 = do
450450 res <- lift $ uncons m1
@@ -588,7 +588,7 @@ mfix f = mkStream $ \st yld sng stp ->
588588
589589{-# INLINE init #-}
590590init :: (IsStream t, Monad m) => t m a -> m (Maybe (t m a))
591−init m = go1 m
591+init = go1
592592 where
593593 go1 m1 = do
594594 r <- uncons m1
@@ -602,7 +602,7 @@ init m = go1 m
602602
603603{-# INLINE elem #-}
604604elem :: (IsStream t, Monad m, Eq a) => a -> t m a -> m Bool
605−elem e m = go m
605+elem e = go
606606 where
607607 go m1 =
608608 let stop = return False
@@ -612,7 +612,7 @@ elem e m = go m
612612
613613{-# INLINE notElem #-}
614614notElem :: (IsStream t, Monad m, Eq a) => a -> t m a -> m Bool
615−notElem e m = go m
615+notElem e = go
616616 where
617617 go m1 =
618618 let stop = return True
@@ -622,7 +622,7 @@ notElem e m = go m
622622
623623{-# INLINABLE all #-}
624624all :: (IsStream t, Monad m) => (a -> Bool) -> t m a -> m Bool
625−all p m = go m
625+all p = go
626626 where
627627 go m1 =
628628 let single a | p a = return True
@@ -633,7 +633,7 @@ all p m = go m
633633
634634{-# INLINABLE any #-}
635635any :: (IsStream t, Monad m) => (a -> Bool) -> t m a -> m Bool
636−any p m = go m
636+any p = go
637637 where
638638 go m1 =
639639 let single a | p a = return True
@@ -649,7 +649,7 @@ last = foldlx' (\_ y -> Just y) Nothing id
649649
650650{-# INLINE minimum #-}
651651minimum :: (IsStream t, Monad m, Ord a) => t m a -> m (Maybe a)
652−minimum m = go Nothing m
652+minimum = go Nothing
653653 where
654654 go Nothing m1 =
655655 let stop = return Nothing
@@ -673,7 +673,7 @@ minimum m = go Nothing m
673673minimumBy
674674 :: (IsStream t, Monad m)
675675 => (a -> a -> Ordering) -> t m a -> m (Maybe a)
676−minimumBy cmp m = go Nothing m
676+minimumBy cmp = go Nothing
677677 where
678678 go Nothing m1 =
679679 let stop = return Nothing
@@ -693,7 +693,7 @@ minimumBy cmp m = go Nothing m
693693
694694{-# INLINE maximum #-}
695695maximum :: (IsStream t, Monad m, Ord a) => t m a -> m (Maybe a)
696−maximum m = go Nothing m
696+maximum = go Nothing
697697 where
698698 go Nothing m1 =
699699 let stop = return Nothing
@@ -715,7 +715,7 @@ maximum m = go Nothing m
715715
716716{-# INLINE maximumBy #-}
717717maximumBy :: (IsStream t, Monad m) => (a -> a -> Ordering) -> t m a -> m (Maybe a)
718−maximumBy cmp m = go Nothing m
718+maximumBy cmp = go Nothing
719719 where
720720 go Nothing m1 =
721721 let stop = return Nothing
@@ -747,7 +747,7 @@ m !! i = go i m
747747
748748{-# INLINE lookup #-}
749749lookup :: (IsStream t, Monad m, Eq a) => a -> t m (a, b) -> m (Maybe b)
750−lookup e m = go m
750+lookup e = go
751751 where
752752 go m1 =
753753 let single (a, b) | a == e = return $ Just b
@@ -758,7 +758,7 @@ lookup e m = go m
758758
759759{-# INLINE findM #-}
760760findM :: (IsStream t, Monad m) => (a -> m Bool) -> t m a -> m (Maybe a)
761−findM p m = go m
761+findM p = go
762762 where
763763 go m1 =
764764 let single a = do
@@ -793,7 +793,7 @@ findIndices p = go 0
793793-- output of the action.
794794{-# INLINE mapM_ #-}
795795mapM_ :: (IsStream t, Monad m) => (a -> m b) -> t m a -> m ()
796−mapM_ f m = go m
796+mapM_ f = go
797797 where
798798 go m1 =
799799 let stop = return ()
@@ -851,7 +851,7 @@ scanl' step begin = scanlx' step begin id
851851
852852{-# INLINE filter #-}
853853filter :: IsStream t => (a -> Bool) -> t m a -> t m a
854−filter p m = go m
854+filter p = go
855855 where
856856 go m1 = mkStream $ \st yld sng stp ->
857857 let single a | p a = sng a
@@ -862,7 +862,7 @@ filter p m = go m
862862
863863{-# INLINE take #-}
864864take :: IsStream t => Int -> t m a -> t m a
865−take n m = go n m
865+take = go
866866 where
867867 go n1 m1 = mkStream $ \st yld sng stp ->
868868 let yieldk a r = yld a (go (n1 - 1) r)
@@ -872,7 +872,7 @@ take n m = go n m
872872
873873{-# INLINE takeWhile #-}
874874takeWhile :: IsStream t => (a -> Bool) -> t m a -> t m a
875−takeWhile p m = go m
875+takeWhile p = go
876876 where
877877 go m1 = mkStream $ \st yld sng stp ->
878878 let single a | p a = sng a
@@ -895,7 +895,7 @@ drop n m = fromStream $ unShare (go n (toStream m))
895895
896896{-# INLINE dropWhile #-}
897897dropWhile :: IsStream t => (a -> Bool) -> t m a -> t m a
898−dropWhile p m = go m
898+dropWhile p = go
899899 where
900900 go m1 = mkStream $ \st yld sng stp ->
901901 let single a | p a = stp
@@ -912,7 +912,7 @@ dropWhile p m = go m
912912-- other stream types to overload it.
913913{-# INLINE sequence #-}
914914sequence :: (IsStream t, MonadAsync m) => t m (m a) -> t m a
915−sequence m = go m
915+sequence = go
916916 where
917917 go m1 = mkStream $ \st yld sng stp ->
918918 let single ma = ma >>= sng
@@ -925,7 +925,7 @@ sequence m = go m
925925
926926{-# INLINE intersperseM #-}
927927intersperseM :: (IsStream t, MonadAsync m) => m a -> t m a -> t m a
928−intersperseM a m = prependingStart m
928+intersperseM a = prependingStart
929929 where
930930 prependingStart m1 = mkStream $ \st yld sng stp ->
931931 let yieldk i x = foldStreamShared st yld sng stp $ return i |: go x
@@ -941,7 +941,7 @@ intersperse a = intersperseM (return a)
941941
942942{-# INLINE insertBy #-}
943943insertBy :: IsStream t => (a -> a -> Ordering) -> a -> t m a -> t m a
944−insertBy cmp x m = go m
944+insertBy cmp x = go
945945 where
946946 go m1 = mkStream $ \st yld _ _ ->
947947 let single a = case cmp x a of
@@ -959,7 +959,7 @@ insertBy cmp x m = go m
959959
960960{-# INLINE deleteBy #-}
961961deleteBy :: IsStream t => (a -> a -> Bool) -> a -> t m a -> t m a
962−deleteBy eq x m = go m
962+deleteBy eq x = go
963963 where
964964 go m1 = mkStream $ \st yld sng stp ->
965965 let single a = if eq x a then stp else sng a
@@ -982,12 +982,10 @@ reverse = foldlS (flip cons) nil
982982
983983{-# INLINE mapMaybe #-}
984984mapMaybe :: IsStream t => (a -> Maybe b) -> t m a -> t m b
985−mapMaybe f m = go m
985+mapMaybe f = go
986986 where
987987 go m1 = mkStream $ \st yld sng stp ->
988− let single a = case f a of
989− Just b -> sng b
990− Nothing -> stp
988+ let single a = maybe stp sng (f a)
991989 yieldk a r = case f a of
992990 Just b -> yld b $ go r
993991 Nothing -> foldStream (adaptState st) yieldk single stp r
@@ -1018,7 +1016,7 @@ zipWith f = go
10181016-- @since 0.1.0
10191017{-# INLINABLE zipWithM #-}
10201018zipWithM :: (IsStream t, Monad m) => (a -> b -> m c) -> t m a -> t m b -> t m c
1021−zipWithM f m1 m2 = go m1 m2
1019+zipWithM f = go
10221020 where
10231021 go mx my = mkStream $ \st yld sng stp -> do
10241022 let merge a ra =
src/Streamly/Internal/Data/Stream/StreamK/Type.hs+14−14
@@ -269,7 +269,7 @@ type StopK m = forall r. m r -> m r
269269type YieldK m a = forall r. (a -> m r) -> m r
270270
271271_wrapM :: Monad m => m a -> YieldK m a
272−_wrapM m = \k -> m >>= k
272+_wrapM m = (m >>=)
273273
274274-- | Make an empty stream from a stop function.
275275fromStopK :: IsStream t => StopK m -> t m a
@@ -282,7 +282,7 @@ fromYieldK k = mkStream $ \_ _ sng _ -> k sng
282282
283283-- | Add a yield function at the head of the stream.
284284consK :: IsStream t => YieldK m a -> t m a -> t m a
285−consK k r = mkStream $ \_ yld _ _ -> k (\x -> yld x r)
285+consK k r = mkStream $ \_ yld _ _ -> k (`yld` r)
286286
287287-- XXX Build a stream from a repeating callback function.
288288
@@ -359,7 +359,7 @@ fromEffect m = fromStream $ mkStream $ \_ _ single _ -> m >>= single
359359{-# INLINE consMBy #-}
360360consMBy :: (IsStream t, MonadAsync m) => (t m a -> t m a -> t m a)
361361 -> m a -> t m a -> t m a
362−consMBy f m r = (fromStream $ fromEffect m) `f` r
362+consMBy f m r = fromStream (fromEffect m) `f` r
363363
364364------------------------------------------------------------------------------
365365-- Folding a stream
@@ -462,7 +462,7 @@ foldrSWith :: IsStream t
462462 -> t m b
463463 -> m r)
464464 -> (a -> t m b -> t m b) -> t m b -> t m a -> t m b
465−foldrSWith f step final m = go m
465+foldrSWith f step final = go
466466 where
467467 go m1 = mkStream $ \st yld sng stp ->
468468 let run x = f st yld sng stp x
@@ -520,7 +520,7 @@ foldrSMWith :: (IsStream t, Monad m)
520520 -> t m b
521521 -> m r)
522522 -> (m a -> t m b -> t m b) -> t m b -> t m a -> t m b
523−foldrSMWith f step final m = go m
523+foldrSMWith f step final = go
524524 where
525525 go m1 = mkStream $ \st yld sng stp ->
526526 let run x = f st yld sng stp x
@@ -658,7 +658,7 @@ sharedM g = mkStream $ \st yld sng stp ->
658658{-# INLINE_NORMAL augmentS #-}
659659augmentS :: IsStream t
660660 => ((a -> t m a -> t m a) -> t m a -> t m a) -> t m a -> t m a
661−augmentS g xs = g cons xs
661+augmentS g = g cons
662662
663663{-# RULES "augmentS/nil"
664664 forall (g :: (a -> t m a -> t m a) -> t m a -> t m a).
@@ -679,7 +679,7 @@ augmentS g xs = g cons xs
679679{-# INLINE_NORMAL augmentSM #-}
680680augmentSM :: (IsStream t, MonadAsync m)
681681 => ((m a -> t m a -> t m a) -> t m a -> t m a) -> t m a -> t m a
682−augmentSM g xs = g consM xs
682+augmentSM g = g consM
683683
684684{-# RULES "augmentSM/nil"
685685 forall (g :: (m a -> t m a -> t m a) -> t m a -> t m a).
@@ -704,7 +704,7 @@ augmentSM g xs = g consM xs
704704-- | Lazy right fold with a monadic step function.
705705{-# INLINE_NORMAL foldrM #-}
706706foldrM :: IsStream t => (a -> m b -> m b) -> m b -> t m a -> m b
707−foldrM step acc m = go m
707+foldrM step acc = go
708708 where
709709 go m1 =
710710 let stop = acc
@@ -724,7 +724,7 @@ foldrMKWith
724724 -> m b
725725 -> ((a -> t m a -> m b) -> (a -> m b) -> m b -> m b)
726726 -> m b
727−foldrMKWith f step acc g = go g
727+foldrMKWith f step acc = go
728728 where
729729 go k =
730730 let stop = acc
@@ -837,7 +837,7 @@ serial m1 m2 = go m1
837837-- join/merge/append streams depending on consM
838838{-# INLINE conjoin #-}
839839conjoin :: (IsStream t, MonadAsync m) => t m a -> t m a -> t m a
840−conjoin xs ys = augmentSM (\c n -> foldrSM c n xs) ys
840+conjoin xs = augmentSM (\c n -> foldrSM c n xs)
841841
842842instance Semigroup (Stream m a) where
843843 (<>) = serial
@@ -858,7 +858,7 @@ instance Monoid (Stream m a) where
858858{-# INLINE_LATE mapFB #-}
859859mapFB :: forall (t :: (Type -> Type) -> Type -> Type) b m a.
860860 (b -> t m b -> t m b) -> (a -> b) -> a -> t m b -> t m b
861−mapFB c f = \x ys -> c (f x) ys
861+mapFB c f x ys = c (f x) ys
862862#undef Type
863863
864864{-# RULES
@@ -886,7 +886,7 @@ map f m = go m
886886
887887{-# INLINE_LATE mapMFB #-}
888888mapMFB :: Monad m => (m b -> t m b -> t m b) -> (a -> m b) -> m a -> t m b -> t m b
889−mapMFB c f = \x ys -> c (x >>= f) ys
889+mapMFB c f x = c (x >>= f)
890890
891891{-# RULES
892892 "mapMFB/mapMFB" forall c f g. mapMFB (mapMFB c f) g = mapMFB c (f >=> g)
@@ -1016,7 +1016,7 @@ apSerialDiscardFst fstream stream = go1 fstream
10161016 go1 m =
10171017 mkStream $ \st yld sng stp ->
10181018 let foldShared = foldStreamShared st yld sng stp
1019− single _ = foldShared $ stream
1019+ single _ = foldShared stream
10201020 yieldk _ r = foldShared $ go2 r stream
10211021 in foldStream (adaptState st) yieldk single stp m
10221022
@@ -1107,7 +1107,7 @@ concatMapBy par f xs = bindWith par xs f
11071107concatMap :: IsStream t => (a -> t m b) -> t m a -> t m b
11081108concatMap f m = fromStream $
11091109 concatMapBy serial
1110− (\a -> adapt $ toStream $ f a)
1110+ (adapt . toStream . f)
11111111 (adapt $ toStream m)
11121112
11131113{-