nanoparsec-0.1.1: An implementation of attoparsec-like parser around list-like

Portabilityportable
Stabilityexperimental
Maintainerbos@serpentine.com

Data.Nanoparsec.Combinator

Contents

Description

Useful parser combinators, similar to those provided by Parsec.

Synopsis

Documentation

choice :: Alternative f => [f a] -> f aSource

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]Source

Apply the given action repeatedly, returning every result.

option :: Alternative f => a -> f a -> f aSource

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]Source

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]Source

sepBy :: Alternative f => f a -> f s -> f [a]Source

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]Source

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 ()Source

skipMany1 :: Alternative f => f a -> f ()Source

eitherP :: Alternative f => f a -> f b -> f (Either a b)Source

Combine two alternatives.

Inlined implementations of existing functions

many :: Alternative f => f a -> f [a]Source

Zero or more.