License | BSD-3-Clause |
---|---|
Maintainer | Jamie Willis |
Stability | stable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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
- (<|>) :: Parser a -> Parser a -> Parser a
- empty :: Parser a
- (<+>) :: Parser a -> Parser b -> Parser (Either a b)
- option :: ParserOps rep => rep a -> Parser a -> Parser a
- optionally :: ParserOps rep => Parser a -> rep b -> Parser b
- optional :: Parser a -> Parser ()
- choice :: [Parser a] -> Parser a
- maybeP :: Parser a -> Parser (Maybe a)
- manyTill :: Parser a -> Parser b -> Parser [a]
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
(<+>) :: 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