Copyright | (c) 2017 Harendra Kumar |
---|---|
License | BSD3 |
Maintainer | harendra.kumar@gmail.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
- cons :: Streaming t => a -> t m a -> t m a
- nil :: Streaming t => t m a
- unfoldr :: Streaming t => (b -> Maybe (a, b)) -> b -> t m a
- unfoldrM :: (Streaming t, Monad m) => (b -> m (Maybe (a, b))) -> b -> t m a
- each :: (Foldable f, Streaming t) => f a -> t m a
- fromHandle :: (MonadIO m, Streaming t) => Handle -> t m String
- foldr :: (Monad m, Streaming t) => (a -> b -> b) -> b -> t m a -> m b
- foldrM :: Streaming t => (a -> m b -> m b) -> m b -> t m a -> m b
- foldl :: (Monad m, Streaming t) => (x -> a -> x) -> x -> (x -> b) -> t m a -> m b
- foldlM :: (Monad m, Streaming t) => (x -> a -> m x) -> m x -> (x -> m b) -> t m a -> m b
- uncons :: (Streaming t, Monad m) => t m a -> m (Maybe (a, t m a))
- toList :: (Monad m, Streaming t) => t m a -> m [a]
- toHandle :: (Streaming t, MonadIO m) => Handle -> t m String -> m ()
- all :: (Streaming t, Monad m) => (a -> Bool) -> t m a -> m Bool
- any :: (Streaming t, Monad m) => (a -> Bool) -> t m a -> m Bool
- sum :: (Streaming t, Monad m, Num a) => t m a -> m a
- product :: (Streaming t, Monad m, Num a) => t m a -> m a
- head :: (Streaming t, Monad m) => t m a -> m (Maybe a)
- last :: (Streaming t, Monad m) => t m a -> m (Maybe a)
- length :: (Streaming t, Monad m) => t m a -> m Int
- elem :: (Streaming t, Monad m, Eq a) => a -> t m a -> m Bool
- notElem :: (Streaming t, Monad m, Eq a) => a -> t m a -> m Bool
- maximum :: (Streaming t, Monad m, Ord a) => t m a -> m (Maybe a)
- minimum :: (Streaming t, Monad m, Ord a) => t m a -> m (Maybe a)
- filter :: (Streaming t, Monad (t m)) => (a -> Bool) -> t m a -> t m a
- take :: Streaming t => Int -> t m a -> t m a
- takeWhile :: Streaming t => (a -> Bool) -> t m a -> t m a
- drop :: Streaming t => Int -> t m a -> t m a
- dropWhile :: Streaming t => (a -> Bool) -> t m a -> t m a
- mapM :: (Streaming t, Monad m) => (a -> m b) -> t m a -> t m b
- mapM_ :: (Streaming t, Monad m) => (a -> m b) -> t m a -> m ()
- sequence :: (Streaming t, Monad m) => t m (m a) -> t m a
- zipWith :: Streaming t => (a -> b -> c) -> t m a -> t m b -> t m c
- zipWithM :: Streaming t => (a -> b -> t m c) -> t m a -> t m b -> t m c
- zipAsyncWith :: (Streaming t, MonadAsync m) => (a -> b -> c) -> t m a -> t m b -> t m c
- zipAsyncWithM :: (Streaming t, MonadAsync m) => (a -> b -> t m c) -> t m a -> t m b -> t m c
Construction
unfoldr :: Streaming t => (b -> Maybe (a, b)) -> b -> t m a Source #
Build a Stream by unfolding pure steps starting from a seed.
unfoldrM :: (Streaming t, Monad m) => (b -> m (Maybe (a, b))) -> b -> t m a Source #
Build a Stream by unfolding monadic steps starting from a seed.
fromHandle :: (MonadIO m, Streaming t) => Handle -> t m String Source #
Read lines from an IO Handle into a stream of Strings.
Elimination
foldrM :: Streaming t => (a -> m b -> m b) -> m b -> t m a -> m b Source #
Right fold with a monadic step function. See toList
for an example use.
foldl :: (Monad m, Streaming t) => (x -> a -> x) -> x -> (x -> b) -> t m a -> m b Source #
Strict left fold. This is typed to work with the foldl package. To use
directly pass id
as the third argument.
foldlM :: (Monad m, Streaming t) => (x -> a -> m x) -> m x -> (x -> m b) -> t m a -> m b Source #
Strict left fold, with monadic step function. This is typed to work
with the foldl package. To use directly pass id
as the third argument.
uncons :: (Streaming t, Monad m) => t m a -> m (Maybe (a, t m a)) Source #
Decompose a stream into its head and tail. If the stream is empty, returns
Nothing
. If the stream is non-empty, returns 'Just (a, ma)', where a
is
the head of the stream and ma
its tail.
Elimination Special Folds
toList :: (Monad m, Streaming t) => t m a -> m [a] Source #
Convert a stream into a list in the underlying monad.
toHandle :: (Streaming t, MonadIO m) => Handle -> t m String -> m () Source #
Write a stream of Strings to an IO Handle.
all :: (Streaming t, Monad m) => (a -> Bool) -> t m a -> m Bool Source #
Determine whether all elements of a stream satisfy a predicate.
any :: (Streaming t, Monad m) => (a -> Bool) -> t m a -> m Bool Source #
Determine whether any of the elements of a stream satisfy a predicate.
sum :: (Streaming t, Monad m, Num a) => t m a -> m a Source #
Determine the sum of all elements of a stream of numbers
product :: (Streaming t, Monad m, Num a) => t m a -> m a Source #
Determine the product of all elements of a stream of numbers
head :: (Streaming t, Monad m) => t m a -> m (Maybe a) Source #
Extract the first element of the stream, if any.
last :: (Streaming t, Monad m) => t m a -> m (Maybe a) Source #
Extract the last element of the stream, if any.
elem :: (Streaming t, Monad m, Eq a) => a -> t m a -> m Bool Source #
Determine whether an element is present in the stream.
notElem :: (Streaming t, Monad m, Eq a) => a -> t m a -> m Bool Source #
Determine whether an element is not present in the stream.
maximum :: (Streaming t, Monad m, Ord a) => t m a -> m (Maybe a) Source #
Determine the maximum element in a stream.
minimum :: (Streaming t, Monad m, Ord a) => t m a -> m (Maybe a) Source #
Determine the minimum element in a stream.
Filtering
filter :: (Streaming t, Monad (t m)) => (a -> Bool) -> t m a -> t m a Source #
Include only those elements that pass a predicate.
take :: Streaming t => Int -> t m a -> t m a Source #
Take first n
elements from the stream and discard the rest.
takeWhile :: Streaming t => (a -> Bool) -> t m a -> t m a Source #
End the stream as soon as the predicate fails on an element.
drop :: Streaming t => Int -> t m a -> t m a Source #
Discard first n
elements from the stream and take the rest.
dropWhile :: Streaming t => (a -> Bool) -> t m a -> t m a Source #
Drop elements in the stream as long as the predicate succeeds and then take the rest of the stream.
Transformation
mapM :: (Streaming t, Monad m) => (a -> m b) -> t m a -> t m b Source #
Replace each element of the stream with the result of a monadic action applied on the element.
mapM_ :: (Streaming t, Monad m) => (a -> m b) -> t m a -> m () Source #
Apply a monadic action to each element of the stream and discard the output of the action.
sequence :: (Streaming t, Monad m) => t m (m a) -> t m a Source #
Reduce a stream of monadic actions to a stream of the output of those actions.
Zipping
zipWith :: Streaming t => (a -> b -> c) -> t m a -> t m b -> t m c Source #
Zip two streams serially using a pure zipping function.
zipWithM :: Streaming t => (a -> b -> t m c) -> t m a -> t m b -> t m c Source #
Zip two streams serially using a monadic zipping function.
zipAsyncWith :: (Streaming t, MonadAsync m) => (a -> b -> c) -> t m a -> t m b -> t m c Source #
Zip two streams asyncly (i.e. both the elements being zipped are generated concurrently) using a pure zipping function.
zipAsyncWithM :: (Streaming t, MonadAsync m) => (a -> b -> t m c) -> t m a -> t m b -> t m c Source #
Zip two streams asyncly (i.e. both the elements being zipped are generated concurrently) using a monadic zipping function.