Module

Text.Parsing.Parser

Package
purescript-parsing
Repository
purescript-contrib/purescript-parsing

#ParseError Source

data ParseError

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

Constructors

Instances

#ParseState Source

data ParseState s

Contains the remaining input and current position.

Constructors

Instances

#ParserT Source

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 Source

type Parser s = ParserT s Identity

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

#runParser Source

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

Apply a parser, keeping only the parsed result.

#runParserT Source

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 Source

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

#mapParserT Source

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 Source

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

Set the consumed flag.

#position Source

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

Returns the current position in the stream.

#fail Source

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

Fail with a message.

#failWithPosition Source

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

Fail with a message and a position.

#region Source

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.