Copyright | (c) 2022 Composewell Technologies |
---|---|
License | BSD-3-Clause |
Maintainer | [email protected] |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
Streamly.Internal.Data.Stream.SVar
Description
Deprecated: This module will be removed in future.
Synopsis
- fromConsumer :: MonadAsync m => SVar Stream m a -> m Bool
- newFoldSVar :: MonadAsync m => State Stream m a -> (SerialT m a -> m b) -> m (SVar Stream m a)
- newFoldSVarF :: forall m (t :: (Type -> Type) -> Type -> Type) a b. MonadAsync m => State t m a -> Fold m a b -> m (SVar t m a)
- pushToFold :: MonadAsync m => SVar Stream m a -> a -> m Bool
- teeToSVar :: forall (m :: Type -> Type) a. MonadAsync m => SVar Stream m a -> SerialT m a -> SerialT m a
- toSVarParallel :: forall m (t :: (Type -> Type) -> Type -> Type) a. MonadAsync m => State t m a -> SVar t m a -> Stream m a -> m ()
- fromSVar :: forall (m :: Type -> Type) a. MonadAsync m => SVar Stream m a -> SerialT m a
- fromSVarD :: forall (m :: Type -> Type) (t :: (Type -> Type) -> Type -> Type) a. MonadAsync m => SVar t m a -> Stream m a
- toSVar :: MonadAsync m => SVar SerialT m a -> SerialT m a -> m ()
Documentation
fromConsumer :: MonadAsync m => SVar Stream m a -> m Bool Source #
newFoldSVar :: MonadAsync m => State Stream m a -> (SerialT m a -> m b) -> m (SVar Stream m a) Source #
Create a Fold style SVar that runs a supplied fold function as the consumer. Any elements sent to the SVar are consumed by the supplied fold function.
newFoldSVarF :: forall m (t :: (Type -> Type) -> Type -> Type) a b. MonadAsync m => State t m a -> Fold m a b -> m (SVar t m a) Source #
Like newFoldSVar
except that it uses a Fold
instead of a fold
function.
pushToFold :: MonadAsync m => SVar Stream m a -> a -> m Bool Source #
Push values from a stream to a fold worker via an SVar. Before pushing a
value to the SVar it polls for events received from the fold consumer. If a
stop event is received then it returns True
otherwise false. Propagates
exceptions received from the fold consumer.
teeToSVar :: forall (m :: Type -> Type) a. MonadAsync m => SVar Stream m a -> SerialT m a -> SerialT m a Source #
Tap a stream and send the elements to the specified SVar in addition to yielding them again. The SVar runs a fold consumer. Elements are tapped and sent to the SVar until the fold finishes. Any exceptions from the fold evaluation are propagated in the current thread.
------input stream---------output stream-----> /|\ | exceptions | | input | \|/ ----SVar | Fold
toSVarParallel :: forall m (t :: (Type -> Type) -> Type -> Type) a. MonadAsync m => State t m a -> SVar t m a -> Stream m a -> m () Source #
Fold the supplied stream to the SVar asynchronously using Parallel concurrency style. {-# INLINE [1] toSVarParallel #-}
fromSVar :: forall (m :: Type -> Type) a. MonadAsync m => SVar Stream m a -> SerialT m a Source #
Generate a stream from an SVar. An unevaluated stream can be pushed to an
SVar using toSVar
. As we pull a stream from the SVar the input stream
gets evaluated concurrently. The evaluation depends on the SVar style and
the configuration parameters e.g. using the maxBuffer/maxThreads
combinators.