Synopsis

# Documentation

newtype ParserState Source #

Constructors

 ParserState FieldsparserStateSince :: Maybe Version

Instances

 Source # Methods Source # MethodsshowList :: [ParserState] -> ShowS #

newtype Parser a Source #

Constructors

 Parser (StateT ParserState Parser a)

Instances

 Source # Methods(>>=) :: Parser a -> (a -> Parser b) -> Parser b #(>>) :: Parser a -> Parser b -> Parser b #return :: a -> Parser a #fail :: String -> Parser a # Source # Methodsfmap :: (a -> b) -> Parser a -> Parser b #(<$) :: a -> Parser b -> Parser a # Source # Methodspure :: a -> Parser a #(<*>) :: Parser (a -> b) -> Parser a -> Parser b #(*>) :: Parser a -> Parser b -> Parser b #(<*) :: Parser a -> Parser b -> Parser a # Source # Methodsempty :: Parser a #(<|>) :: Parser a -> Parser a -> Parser a #some :: Parser a -> Parser [a] #many :: Parser a -> Parser [a] # Source # Methodsmzero :: Parser a #mplus :: Parser a -> Parser a -> Parser a # (~) * a ByteString => IsString (Parser a) Source # Methods lift :: Parser a -> Parser a Source # scan :: s -> (s -> Char -> Maybe s) -> Parser ByteString Source # A fast digit predicate. A fast digit predicate. A fast alphabetic predicate for the ISO-8859-15 encoding Note: For all character encodings other than ISO-8859-15, and almost all Unicode code points above U+00A3, this predicate gives wrong answers. A fast alphabetic predicate for the ASCII encoding Note: For all character encodings other than ASCII, and almost all Unicode code points above U+007F, this predicate gives wrong answers. Fast predicate for matching ASCII space characters. Note: This predicate only gives correct answers for the ASCII encoding. For instance, it does not recognise U+00A0 (non-breaking space) as a space character, even though it is a valid ISO-8859-15 byte. For a Unicode-aware and only slightly slower predicate, use isSpace Fast Word8 predicate for matching ASCII space characters. Match any character in a set. vowel = inClass "aeiou" Range notation is supported. halfAlphabet = inClass "a-nA-N" To add a literal '-' to a set, place it at the beginning or end of the string. Match any character not in a set. A predicate that matches either a carriage return '\r' or newline '\n' character. A predicate that matches either a space ' ' or horizontal tab '\t' character. choice :: Alternative f => [f a] -> f a Source # 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 a Source # 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)

many' :: MonadPlus m => m a -> m [a] Source #

many' p applies the action p zero or more times. Returns a list of the returned values of p. The value returned by p is forced to WHNF.

 word  = many' letter

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

many1' :: MonadPlus m => m a -> m [a] Source #

many1' p applies the action p one or more times. Returns a list of the returned values of p. The value returned by p is forced to WHNF.

 word  = many1' letter

manyTill :: Alternative f => f a -> f b -> f [a] Source #

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 (string "-->")

(Note the overlapping parsers anyChar and string "-->". While this will work, it is not very efficient, as it will cause a lot of backtracking.)

manyTill' :: MonadPlus m => m a -> m b -> m [a] Source #

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 (string "-->")

(Note the overlapping parsers anyChar and string "-->". While this will work, it is not very efficient, as it will cause a lot of backtracking.)

The value returned by p is forced to WHNF.

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 ",")

sepBy' :: MonadPlus m => m a -> m s -> m [a] Source #

sepBy' p sep applies zero or more occurrences of p, separated by sep. Returns a list of the values returned by p. The value returned by p is forced to WHNF.

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 sepBy1 (symbol ",")

sepBy1' :: MonadPlus m => m a -> m s -> m [a] Source #

sepBy1' p sep applies one or more occurrences of p, separated by sep. Returns a list of the values returned by p. The value returned by p is forced to WHNF.

commaSep p  = p sepBy1' (symbol ",")

skipMany :: Alternative f => f a -> f () Source #

Skip zero or more instances of an action.

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

Skip one or more instances of an action.

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

Combine two alternatives.