streamly-core-0.1.0: Streaming, parsers, arrays and more
Copyright(c) 2018 Composewell Technologies
LicenseBSD-3-Clause
Maintainerstreamly@composewell.com
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

Streamly.Internal.Data.Stream.StreamD.Lift

Description

Transform the underlying monad of a stream.

Synopsis

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.