attoparsec-0.14.4: Fast combinator parsing for bytestrings and text

Copyright | Bryan O'Sullivan 2007-2015
License | BSD3
Maintainer | bos@serpentine.com
Stability | experimental
Portability | unknown
Safe Haskell | Trustworthy
Language | Haskell2010

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

- type Parser a = ZeptoT Identity a
- data ZeptoT (m :: Type -> Type) a
- parse :: Parser a -> ByteString -> Either String a
- parseT :: Monad m => ZeptoT m a -> ByteString -> m (Either String a)
- atEnd :: forall (m :: Type -> Type). Monad m => ZeptoT m Bool
- string :: forall (m :: Type -> Type). Monad m => ByteString -> ZeptoT m ()
- take :: forall (m :: Type -> Type). Monad m => Int -> ZeptoT m ByteString
- takeWhile :: forall (m :: Type -> Type). Monad m => (Word8 -> Bool) -> ZeptoT m ByteString

# Documentation

type Parser a = ZeptoT Identity a Source #

data ZeptoT (m :: Type -> Type) 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

Instances details

MonadIO m => MonadIO (ZeptoT m) Source # |
Instance details Defined in Data.Attoparsec.Zepto Methods liftIO :: IO a -> ZeptoT m a Source #
Monad m => Alternative (ZeptoT m) Source # |
Instance details Defined in Data.Attoparsec.Zepto Methods empty :: ZeptoT m a Source # (<|>) :: ZeptoT m a -> ZeptoT m a -> ZeptoT m a Source # some :: ZeptoT m a -> ZeptoT m [a] Source # many :: ZeptoT m a -> ZeptoT m [a] Source #
Monad m => Applicative (ZeptoT m) Source # |
Instance details Defined in Data.Attoparsec.Zepto Methods pure :: a -> ZeptoT m a Source # (<*>) :: ZeptoT m (a -> b) -> ZeptoT m a -> ZeptoT m b Source # liftA2 :: (a -> b -> c) -> ZeptoT m a -> ZeptoT m b -> ZeptoT m c Source # (*>) :: ZeptoT m a -> ZeptoT m b -> ZeptoT m b Source # (<*) :: ZeptoT m a -> ZeptoT m b -> ZeptoT m a Source #
Monad m => Functor (ZeptoT m) Source # |
Instance details Defined in Data.Attoparsec.Zepto Methods fmap :: (a -> b) -> ZeptoT m a -> ZeptoT m b Source # (<$) :: a -> ZeptoT m b -> ZeptoT m a Source #
Monad m => Monad (ZeptoT m) Source # |
Instance details Defined in Data.Attoparsec.Zepto Methods (>>=) :: ZeptoT m a -> (a -> ZeptoT m b) -> ZeptoT m b Source # (>>) :: ZeptoT m a -> ZeptoT m b -> ZeptoT m b Source # return :: a -> ZeptoT m a Source #
Monad m => MonadPlus (ZeptoT m) Source # |
Instance details Defined in Data.Attoparsec.Zepto Methods mzero :: ZeptoT m a Source # mplus :: ZeptoT m a -> ZeptoT m a -> ZeptoT m a Source #
Monad m => MonadFail (ZeptoT m) Source # |
Instance details Defined in Data.Attoparsec.Zepto Methods fail :: String -> ZeptoT m a Source #
Monad m => Monoid (ZeptoT m a) Source # |
Instance details Defined in Data.Attoparsec.Zepto Methods mempty :: ZeptoT m a Source # mappend :: ZeptoT m a -> ZeptoT m a -> ZeptoT m a Source # mconcat :: [ZeptoT m a] -> ZeptoT m a Source #
Monad m => Semigroup (ZeptoT m a) Source # |
Instance details Defined in Data.Attoparsec.Zepto Methods (<>) :: ZeptoT m a -> ZeptoT m a -> ZeptoT m a Source # sconcat :: NonEmpty (ZeptoT m a) -> ZeptoT m a Source # stimes :: Integral b => b -> ZeptoT m a -> ZeptoT m a Source #

parse :: Parser a -> ByteString -> Either String a Source #

Run a parser.

parseT :: Monad m => ZeptoT m a -> ByteString -> m (Either String a) Source #

Run a parser on top of the given base monad.

atEnd :: forall (m :: Type -> Type). Monad m => ZeptoT m Bool Source #

Indicate whether the end of the input has been reached.

string :: forall (m :: Type -> Type). Monad m => ByteString -> ZeptoT m () Source #

Match a string exactly.

take :: forall (m :: Type -> Type). Monad m => Int -> ZeptoT m ByteString Source #

Consume `n` bytes of input.

takeWhile :: forall (m :: Type -> Type). Monad m => (Word8 -> Bool) -> ZeptoT m ByteString Source #

Consume input while the predicate returns `True`.