@@ -111,8 +111,6 @@ module Streamly.Internal.Data.Stream.Channel.Types
111111
112112 , withDiagMVar
113113 , printSVar
114−
115− , concatMapDivK
116114 )
117115where
118116
@@ -127,13 +125,11 @@ import Data.IORef (IORef, newIORef, readIORef, writeIORef)
127125import Data.Set (Set)
128126import Streamly.Internal.Data.Atomics
129127 (atomicModifyIORefCAS, atomicModifyIORefCAS_, storeLoadBarrier)
130−import Streamly.Internal.Data.SVar.Type (adaptState)
131128import Streamly.Internal.Data.Time.Clock (Clock(Monotonic), getTime)
132129import Streamly.Internal.Data.Time.Units (AbsTime, NanoSecond64(..))
133130import System.IO (hPutStrLn, stderr)
134131
135132import qualified Data.Set as Set
136−import qualified Streamly.Internal.Data.StreamK as K
137133
138134------------------------------------------------------------------------------
139135-- Common types
@@ -819,25 +815,3 @@ cleanupSVar workerSet = do
819815 Prelude.mapM_ (`throwTo` ThreadAbort)
820816 -- (Prelude.filter (/= self) $ Set.toList workers)
821817 (Set.toList workers)
822−
823−-------------------------------------------------------------------------------
824−-- Evaluator
825−-------------------------------------------------------------------------------
826−
827−-- | @concatMapDivK useTail useHead stream@, divides the stream in head and
828−-- tail, maps a stream generator on the head and maps an action on the tail of
829−-- a stream. Returns the stream generated by the head.
830−--
831−-- Used for concurrent evaluation of streams using a Channel.
832−{-# INLINE concatMapDivK #-}
833−concatMapDivK :: Monad m =>
834− (K.StreamK m a -> m ())
835− -> (a -> K.StreamK m b)
836− -> K.StreamK m a
837− -> K.StreamK m b
838−concatMapDivK useTail useHead stream =
839− K.mkStream $ \st yld sng stp -> do
840− let foldShared = K.foldStreamShared st yld sng stp
841− single a = foldShared $ useHead a
842− yieldk a r = useTail r >> single a
843− in K.foldStreamShared (adaptState st) yieldk single stp stream