Copyright | (c) 2021 Composewell Technologies |
---|---|
License | BSD-3-Clause |
Maintainer | streamly@composewell.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- data Source a b
- source :: Maybe a -> Source a b
- unread :: [b] -> Source a b -> Source a b
- isEmpty :: Source a b -> Bool
- producer :: Monad m => Producer m a b -> Producer m (Source a b) b
- parse :: MonadThrow m => Parser m a b -> Producer m (Source s a) a -> Source s a -> m (b, Source s a)
- parseMany :: MonadThrow m => Parser m a b -> Producer m (Source x a) a -> Producer m (Source x a) b
- parseManyD :: MonadThrow m => Parser m a b -> Producer m (Source x a) a -> Producer m (Source x a) b
Documentation
A seed with a buffer. It allows us to unread
or return some data
after reading it. Useful in backtracked parsing.
Creation
source :: Maybe a -> Source a b Source #
Make a source from a seed value. The buffer would start as empty.
Pre-release
Transformation
unread :: [b] -> Source a b -> Source a b Source #
Return some unused data back to the source. The data is prepended (or consed) to the source.
Pre-release
Consumption
producer :: Monad m => Producer m a b -> Producer m (Source a b) b Source #
Convert a producer to a producer from a buffered source. Any buffered data is read first and then the seed is unfolded.
Pre-release
Parsing
parse :: MonadThrow m => Parser m a b -> Producer m (Source s a) a -> Source s a -> m (b, Source s a) Source #
Parse a buffered source using a parser, returning the parsed value and the remaining source.
Pre-release
parseMany :: MonadThrow m => Parser m a b -> Producer m (Source x a) a -> Producer m (Source x a) b Source #
Apply a parser repeatedly on a buffered source producer to generate a producer of parsed values.
Pre-release
parseManyD :: MonadThrow m => Parser m a b -> Producer m (Source x a) a -> Producer m (Source x a) b Source #