Copyright | (c) 2019 Composewell Technologies |
---|---|
License | BSD3 |
Maintainer | streamly@composewell.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
There are three fundamental types in streamly. They are streams (Streamly.Data.Stream), pipes (Streamly.Internal.Data.Pipe) and folds (Streamly.Data.Fold). Streams are sources or producers of values, multiple sources can be merged into a single source but a source cannot be split into multiple stream sources. Folds are sinks or consumers, a stream can be split and distributed to multiple folds but the results cannot be merged back into a stream source again. Pipes are transformations, a stream source can be split and distributed to multiple pipes each pipe can apply its own transform on the stream and the results can be merged back into a single pipe. Pipes can be attached to a source to produce a source or they can be attached to a fold to produce a fold, or multiple pipes can be merged or zipped into a single pipe.
import qualified Streamly.Internal.Data.Pipe as Pipe
Synopsis
- data Step s a
- data Pipe m a b = forall s1 s2. Pipe (s1 -> a -> m (Step (PipeState s1 s2) b)) (s2 -> m (Step (PipeState s1 s2) b)) s1
- data PipeState s1 s2
- zipWith :: Monad m => (a -> b -> c) -> Pipe m i a -> Pipe m i b -> Pipe m i c
- tee :: Monad m => Pipe m a b -> Pipe m a b -> Pipe m a b
- map :: Monad m => (a -> b) -> Pipe m a b
- compose :: Monad m => Pipe m b c -> Pipe m a b -> Pipe m a c
- mapM :: Monad m => (a -> m b) -> Pipe m a b
Pipe Type
forall s1 s2. Pipe (s1 -> a -> m (Step (PipeState s1 s2) b)) (s2 -> m (Step (PipeState s1 s2) b)) s1 |
Represents a stateful transformation over an input stream of values of
type a
to outputs of type b
in Monad
m
.
zipWith :: Monad m => (a -> b -> c) -> Pipe m i a -> Pipe m i b -> Pipe m i c Source #
The composed pipe distributes the input to both the constituent pipes and zips the output of the two using a supplied zipping function.
Since: 0.7.0
tee :: Monad m => Pipe m a b -> Pipe m a b -> Pipe m a b Source #
The composed pipe distributes the input to both the constituent pipes and merges the outputs of the two.
Since: 0.7.0
compose :: Monad m => Pipe m b c -> Pipe m a b -> Pipe m a c Source #
Compose two pipes such that the output of the second pipe is attached to the input of the first pipe.
Since: 0.7.0