Data.Attoparsec.Combinator

| attoparsec-0.8.1.0: Fast combinator parsing for bytestrings | Contents | Index
Data.Attoparsec.Combinator |
Portability | portable
Stability | experimental
Maintainer | bos@serpentine.com
Contents
Inlined implementations of existing functions
Description
Useful parser combinators, similar to those provided by Parsec.
Synopsis
choice :: Alternative f => [f a] -> f a
count :: Monad m => Int -> m a -> m [a]
option :: Alternative f => a -> f a -> f a
many1 :: Alternative f => f a -> f [a]
manyTill :: Alternative f => f a -> f b -> f [a]
sepBy :: Alternative f => f a -> f s -> f [a]
sepBy1 :: Alternative f => f a -> f s -> f [a]
skipMany :: Alternative f => f a -> f ()
skipMany1 :: Alternative f => f a -> f ()
eitherP :: Alternative f => f a -> f b -> f (Either a b)
many :: Alternative f => f a -> f [a]
Documentation
choice :: Alternative f => [f a] -> f a
`choice ps` tries to apply the actions in the list `ps` in order, until one of them succeeds. Returns the value of the succeeding action.
count :: Monad m => Int -> m a -> m [a]
Apply the given action repeatedly, returning every result.
option :: Alternative f => a -> f a -> f a
`option x p` tries to apply action `p`. If `p` fails without consuming input, it returns the value `x`, otherwise the value returned by `p`.
     priority  = option 0 (digitToInt <$> digit)
many1 :: Alternative f => f a -> f [a]
`many1 p` applies the action `p` one or more times. Returns a list of the returned values of `p`.
      word  = many1 letter
manyTill :: Alternative f => f a -> f b -> f [a]
`manyTill p end` applies action `p` zero or more times until action `end` succeeds, and returns the list of values returned by `p`. This can be used to scan comments:
      simpleComment   = string "<!--" *> manyTill anyChar (try (string "-->"))
Note the overlapping parsers `anyChar` and `string "<!--"`, and therefore the use of the try combinator.
sepBy :: Alternative f => f a -> f s -> f [a]
`sepBy p sep` applies zero or more occurrences of `p`, separated by `sep`. Returns a list of the values returned by `p`.
     commaSep p  = p `sepBy` (symbol ",")
sepBy1 :: Alternative f => f a -> f s -> f [a]
`sepBy1 p sep` applies one or more occurrences of `p`, separated by `sep`. Returns a list of the values returned by `p`.
     commaSep p  = p `sepBy` (symbol ",")
skipMany :: Alternative f => f a -> f ()
Skip zero or more instances of an action.
skipMany1 :: Alternative f => f a -> f ()
Skip one or more instances of an action.
eitherP :: Alternative f => f a -> f b -> f (Either a b)
Combine two alternatives.
Inlined implementations of existing functions
many :: Alternative f => f a -> f [a]
Zero or more.
Produced by Haddock version 2.7.2