@@ -161,8 +161,7 @@ import Streamly.Internal.Data.Refold.Type (Refold (..))
161161import Streamly.Internal.Data.Parser (Parser (..))
162162import Streamly.Internal.Data.Array.Foreign.Type (Array)
163163import Streamly.Internal.Data.Stream.IsStream.Common
164− ( concatMap
165− , fold
164+ ( fold
166165 , interjectSuffix
167166 , intersperseM
168167 , map
@@ -182,7 +181,9 @@ import qualified Streamly.Internal.Data.Fold as FL
182181import qualified Streamly.Internal.Data.Parser.ParserD as PRD
183182import qualified Streamly.Internal.Data.Stream.IsStream.Type as IsStream
184183import qualified Streamly.Internal.Data.Stream.StreamD as D
184+import qualified Streamly.Internal.Data.Stream.IsStream.Expand as Expand
185185import qualified Streamly.Internal.Data.Stream.IsStream.Transform as Transform
186+import qualified Streamly.Internal.Data.Unfold as Unfold
186187
187188import Prelude hiding (concatMap, map)
188189
@@ -1189,7 +1190,10 @@ data SessionEntry a b = LiveSession !a !b | ZombieSession
11891190-- (3,"abc")
11901191--
11911192-- /Pre-release/
1192−--
1193+
1194+-- XXX this fuses with INLINE but it may be too much work for the compiler.
1195+-- Maybe we can NOINLINE the heap processing stuff and then INLINE it to reduce
1196+-- the code bloat.
11931197{-# INLINABLE classifySessionsBy #-}
11941198classifySessionsBy
11951199 :: (IsStream t, MonadAsync m, Ord k)
@@ -1202,7 +1206,7 @@ classifySessionsBy
12021206 -> t m (k, b) -- ^ session key, fold result
12031207classifySessionsBy tick reset ejectPred tmout
12041208 (Fold step initial extract) input =
1205− concatMap sessionOutputStream
1209+ Expand.unfoldMany (Unfold.lmap sessionOutputStream Unfold.fromStream)
12061210 $ scanlMAfter' sstep (return szero) flush
12071211 $ interjectSuffix tick (return Nothing)
12081212 $ map Just input