Copyright | (c) 2018 Composewell Technologies |
---|---|
License | BSD-3-Clause |
Maintainer | streamly@composewell.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Transform the underlying monad of a stream using a monad transfomer.
Synopsis
- foldlT :: (Monad m, Monad (s m), MonadTrans s) => (s m b -> a -> s m b) -> s m b -> Stream m a -> s m b
- foldrT :: (Monad m, Monad (t m), MonadTrans t) => (a -> t m b -> t m b) -> t m b -> Stream m a -> t m b
- liftInner :: (Monad m, MonadTrans t, Monad (t m)) => Stream m a -> Stream (t m) a
- runReaderT :: Monad m => m s -> Stream (ReaderT s m) a -> Stream m a
- usingReaderT :: Monad m => m r -> (Stream (ReaderT r m) a -> Stream (ReaderT r m) a) -> Stream m a -> Stream m a
- evalStateT :: Monad m => m s -> Stream (StateT s m) a -> Stream m a
- runStateT :: Monad m => m s -> Stream (StateT s m) a -> Stream m (s, a)
- usingStateT :: Monad m => m s -> (Stream (StateT s m) a -> Stream (StateT s m) a) -> Stream m a -> Stream m a
Documentation
foldlT :: (Monad m, Monad (s m), MonadTrans s) => (s m b -> a -> s m b) -> s m b -> Stream m a -> s m b Source #
Lazy left fold to a transformer monad.
foldrT :: (Monad m, Monad (t m), MonadTrans t) => (a -> t m b -> t m b) -> t m b -> Stream m a -> t m b Source #
Right fold to a transformer monad. This is the most general right fold
function. foldrS
is a special case of foldrT
, however foldrS
implementation can be more efficient:
>>>
foldrS = Stream.foldrT
>>>
step f x xs = lift $ f x (runIdentityT xs)
>>>
foldrM f z s = runIdentityT $ Stream.foldrT (step f) (lift z) s
foldrT
can be used to translate streamly streams to other transformer
monads e.g. to a different streaming type.
Pre-release
Transform Inner Monad
liftInner :: (Monad m, MonadTrans t, Monad (t m)) => Stream m a -> Stream (t m) a Source #
Lift the inner monad m
of Stream m a
to t m
where t
is a monad
transformer.
runReaderT :: Monad m => m s -> Stream (ReaderT s m) a -> Stream m a Source #
Evaluate the inner monad of a stream as ReaderT
.
usingReaderT :: Monad m => m r -> (Stream (ReaderT r m) a -> Stream (ReaderT r m) a) -> Stream m a -> Stream m a Source #
Run a stream transformation using a given environment.
evalStateT :: Monad m => m s -> Stream (StateT s m) a -> Stream m a Source #
Evaluate the inner monad of a stream as StateT
.
>>>
evalStateT s = fmap snd . Stream.runStateT s