Copyright | (c) 2018 Composewell Technologies |
---|---|
License | BSD-3-Clause |
Maintainer | streamly@composewell.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
Transform the underlying monad of a stream.
Synopsis
- morphInner :: Monad n => (forall x. m x -> n x) -> Stream m a -> Stream n a
- generalizeInner :: Monad m => Stream Identity a -> Stream m a
- liftInnerWith :: Monad (t m) => (forall b. m b -> t m b) -> Stream m a -> Stream (t m) a
- runInnerWith :: Monad m => (forall b. t m b -> m b) -> Stream (t m) a -> Stream m a
- runInnerWithState :: Monad m => (forall b. s -> t m b -> m (b, s)) -> m s -> Stream (t m) a -> Stream m (s, a)
Generalize Inner Monad
morphInner :: Monad n => (forall x. m x -> n x) -> Stream m a -> Stream n a Source #
Transform the inner monad of a stream using a natural transformation.
Example, generalize the inner monad from Identity to any other:
>>>
generalizeInner = Stream.morphInner (return . runIdentity)
Also known as hoist.
generalizeInner :: Monad m => Stream Identity a -> Stream m a Source #
Generalize the inner monad of the stream from Identity
to any monad.
Definition:
>>>
generalizeInner = Stream.morphInner (return . runIdentity)
Transform Inner Monad
liftInnerWith :: Monad (t m) => (forall b. m b -> t m b) -> Stream m a -> Stream (t m) a Source #
Lift the inner monad m
of a stream Stream m a
to t m
using the
supplied lift function.
runInnerWith :: Monad m => (forall b. t m b -> m b) -> Stream (t m) a -> Stream m a Source #
Evaluate the inner monad of a stream using the supplied runner function.
runInnerWithState :: Monad m => (forall b. s -> t m b -> m (b, s)) -> m s -> Stream (t m) a -> Stream m (s, a) Source #
Evaluate the inner monad of a stream using the supplied stateful runner function and the initial state. The state returned by an invocation of the runner is supplied as input state to the next invocation.