Copyright | (c) 2021 Composewell Technologies |
---|---|
License | BSD-3-Clause |
Maintainer | streamly@composewell.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | Safe-Inferred |
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 :: Monad m => Parser a m b -> Producer m (Source s a) a -> Source s a -> m (Either ParseError b, Source s a)
- parseMany :: Monad m => Parser a m b -> Producer m (Source x a) a -> Producer m (Source x a) (Either ParseError b)
- parseManyD :: Monad m => Parser a m b -> Producer m (Source x a) a -> Producer m (Source x a) (Either ParseError 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 :: Monad m => Parser a m b -> Producer m (Source s a) a -> Source s a -> m (Either ParseError b, Source s a) Source #