attoparsec-0.10.4.0: Fast combinator parsing for bytestrings and text

Portability | unknown
Stability | experimental
Maintainer | bos@serpentine.com
Safe Haskell | None

Data.Attoparsec.Zepto

Description

A tiny, highly specialized combinator parser for `ByteString` strings.

While the main Attoparsec module generally performs well, this module is particularly fast for simple non-recursive loops that should not normally result in failed parses.

Warning: on more complex inputs involving recursion or failure, parsers based on this module may be as much as ten times slower than regular Attoparsec! You should only use this module when you have benchmarks that prove that its use speeds your code up.

Synopsis

- data Parser a
- parse :: Parser a -> ByteString -> Either String a
- atEnd :: Parser Bool
- string :: ByteString -> Parser ()
- take :: Int -> Parser ByteString
- takeWhile :: (Word8 -> Bool) -> Parser ByteString

# Documentation

data Parser a Source

A simple parser.

This monad is strict in its state, and the monadic bind operator (`>>=`) evaluates each result to weak head normal form before passing it along.

Instances

Monad Parser |
Functor Parser |
MonadPlus Parser |
Applicative Parser |
Alternative Parser |
Monoid (Parser a) |

parse :: Parser a -> ByteString -> Either String aSource

Run a parser.

atEnd :: Parser Bool Source

Indicate whether the end of the input has been reached.

string :: ByteString -> Parser ()Source

Match a string exactly.

take :: Int -> Parser ByteString Source

Consume `n` bytes of input.

takeWhile :: (Word8 -> Bool) -> Parser ByteString Source

Consume input while the predicate returns `True`.