Module

Text.Parsing.Parser

#ParseError

data ParseError

A parsing error, consisting of a message and position information.

Constructors

Instances

#parseErrorMessage

#parseErrorPosition

#ParseState

data ParseState s

Contains the remaining input and current position.

Constructors

Instances

#ParserT

newtype ParserT :: Type -> (Type -> Type) -> Type -> Typenewtype ParserT s m a

The Parser monad transformer.

The first type argument is the stream type. Typically, this is either String, or some sort of token stream.

Constructors

Instances

#Parser

type Parser s = ParserT s Identity

The Parser monad is a synonym for the parser monad transformer applied to the Identity monad.

#runParser

runParser :: forall s a. s -> Parser s a -> Either ParseError a

Apply a parser, keeping only the parsed result.

#runParserT

runParserT :: forall m s a. Monad m => s -> ParserT s m a -> m (Either ParseError a)

Apply a parser, keeping only the parsed result.

#hoistParserT

hoistParserT :: forall s m n a. (m ~> n) -> ParserT s m a -> ParserT s n a

#mapParserT

mapParserT :: forall b n s a m. (m (Tuple (Either ParseError a) (ParseState s)) -> n (Tuple (Either ParseError b) (ParseState s))) -> ParserT s m a -> ParserT s n b

Change the underlying monad action and data type in a ParserT monad action.

#consume

consume :: forall s m. Monad m => ParserT s m Unit

Set the consumed flag.

#position

position :: forall s m. Monad m => ParserT s m Position

Returns the current position in the stream.

#fail

fail :: forall m s a. Monad m => String -> ParserT s m a

Fail with a message.

#failWithPosition

failWithPosition :: forall m s a. Monad m => String -> Position -> ParserT s m a

Fail with a message and a position.

#region

region :: forall m s a. Monad m => (ParseError -> ParseError) -> ParserT s m a -> ParserT s m a

Contextualize parsing failures inside a region. If a parsing failure occurs, then the ParseError will be transformed by each containing region as the parser backs out the call stack.

Modules