parsley-2.0.0.1: A fast parser combinator library backed by Typed Template Haskell
LicenseBSD-3-Clause
MaintainerJamie Willis
Stabilitystable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Parsley.Alternative

Description

This modules contains the Alternative combinators that would normally be found in Control.Applicative. However, since Parsley makes use of staging, the signatures of these combinators do not correctly match the signatures of those in base Haskell (due to a lack of Applicative constraint).

Since: 0.1.0.0

Synopsis

Documentation

(<|>) :: Parser a -> Parser a -> Parser a infixr 3 Source #

This combinator implements branching within a parser. It is left-biased, so that if the first branch succeeds, the second will not be attempted. In accordance with parsec semantics, if the first branch failed having consumed input the second branch cannot be taken. (see try)

Since: 0.1.0.0

empty :: Parser a Source #

This combinator always fails.

Since: 0.1.0.0

(<+>) :: Parser a -> Parser b -> Parser (Either a b) infixl 3 Source #

This combinator is similar to (<|>), except it allows both branches to differ in type by producing a co-product as a result.

Since: 0.1.0.0

option :: ParserOps rep => rep a -> Parser a -> Parser a Source #

option x p first tries to parse p and, if it fails without consuming input, will return x as a result.

Since: 0.1.0.0

optionally :: ParserOps rep => Parser a -> rep b -> Parser b Source #

optionally p x will try to parse p and will always return x. If p fails having consumed input, then this combinator will fail.

Since: 0.1.0.0

optional :: Parser a -> Parser () Source #

Attempts to parse a given parser, and will always return (). (See optionally)

Since: 0.1.0.0

choice :: [Parser a] -> Parser a Source #

Tries to parse each of the given parsers in turn until one of them succeeds using (<|>). If given the empty list, it will fail unconditionally.

Since: 0.1.0.0

maybeP :: Parser a -> Parser (Maybe a) Source #

Tries to parse a given parser, returning its result in Just if it succeeds and Nothing if it fails having not consumed input.

Since: 0.1.0.0

manyTill :: Parser a -> Parser b -> Parser [a] Source #

The combinator someTill p end will try and parse p as many times as possible so long as end cannot be successfully parsed. It will return the results from the successful parses of p.

Since: 0.1.0.0