Module

StringParser.Combinators

Package
purescript-string-parsers
Repository
purescript-contrib/purescript-string-parsers

This module defines combinators for building string parsers.

#try Source

try :: forall a. Parser a -> Parser a

try p means: run p but do not consume input in case of failure.

#lookAhead Source

lookAhead :: forall a. Parser a -> Parser a

lookAhead p means: run p but do not consume input in case of success. In most cases you will probably want to use tryAhead instead.

#tryAhead Source

tryAhead :: forall a. Parser a -> Parser a

Read ahead without consuming input. tryAhead p means: succeed if what comes next is of the form p; fail otherwise.

#many Source

many :: forall a. Parser a -> Parser (List a)

Match a parser zero or more times. Stops matching when the parser fails or does not consume anymore.

#many1 Source

many1 :: forall a. Parser a -> Parser (NonEmptyList a)

Match a parser one or more times. Stops matching when the parser fails or does not consume anymore.

#manyTill Source

manyTill :: forall a end. Parser a -> Parser end -> Parser (List a)

Match a parser until a terminator parser matches. Fails when the parser does not consume anymore.

#many1Till Source

many1Till :: forall a end. Parser a -> Parser end -> Parser (NonEmptyList a)

Match a parser until a terminator parser matches, requiring at least one match. Fails when the parser does not consume anymore.

#assertConsume Source

assertConsume :: forall a. Parser a -> Parser a

Run given parser and fail if the parser did not consume any input.

#withError Source

withError :: forall a. Parser a -> String -> Parser a

Provide an error message in case of failure.

#(<?>) Source

Operator alias for StringParser.Combinators.withError (left-associative / precedence 4)

#between Source

between :: forall a open close. Parser open -> Parser close -> Parser a -> Parser a

Parse a string between opening and closing markers.

#option Source

option :: forall a. a -> Parser a -> Parser a

Parse a value with a default value in case of failure.

#optional Source

optional :: forall a. Parser a -> Parser Unit

Attempt to parse a value.

#optionMaybe Source

optionMaybe :: forall a. Parser a -> Parser (Maybe a)

Attempt to parse a value, pureing Nothing in case of failure.

#sepBy Source

sepBy :: forall a sep. Parser a -> Parser sep -> Parser (List a)

Parse zero or more separated values.

#sepBy1 Source

sepBy1 :: forall a sep. Parser a -> Parser sep -> Parser (NonEmptyList a)

Parse one or more separated values.

#sepEndBy Source

sepEndBy :: forall a sep. Parser a -> Parser sep -> Parser (List a)

Parse zero or more separated values, optionally ending with a separator.

#sepEndBy1 Source

sepEndBy1 :: forall a sep. Parser a -> Parser sep -> Parser (NonEmptyList a)

Parse one or more separated values, optionally ending with a separator.

#endBy1 Source

endBy1 :: forall a sep. Parser a -> Parser sep -> Parser (NonEmptyList a)

Parse one or more separated values, ending with a separator.

#endBy Source

endBy :: forall a sep. Parser a -> Parser sep -> Parser (List a)

Parse zero or more separated values, ending with a separator.

#chainr Source

chainr :: forall a. Parser a -> Parser (a -> a -> a) -> a -> Parser a

Parse zero or more values separated by a right-associative operator.

#chainl Source

chainl :: forall a. Parser a -> Parser (a -> a -> a) -> a -> Parser a

Parse zero or more values separated by a left-associative operator.

#chainl1 Source

chainl1 :: forall a. Parser a -> Parser (a -> a -> a) -> Parser a

Parse one or more values separated by a left-associative operator.

#chainr1 Source

chainr1 :: forall a. Parser a -> Parser (a -> a -> a) -> Parser a

Parse one or more values separated by a right-associative operator.

#choice Source

choice :: forall f a. Foldable f => f (Parser a) -> Parser a

Parse using any of a collection of parsers.

Re-exports from Control.Lazy

#fix Source

fix :: forall l. Lazy l => (l -> l) -> l

fix defines a value as the fixed point of a function.

The Lazy instance allows us to generate the result lazily.