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.ParserOps

Description

This module contains the definition of ParserOps, which is used to generalise the representation of user-defined functions to either Defunc or WQ.

Since: 2.0.0.0

Synopsis

Documentation

class ParserOps rep where Source #

This typeclass is used to allow abstraction of the representation of user-level functions. See the instances for information on what these representations are. This may be required as a constraint on custom built combinators that make use of one of the minimal required methods of this class.

Since: 0.1.0.0

Methods

pure :: rep a -> Parser a Source #

Lift a value into the parser world without consuming input or having any other effect.

Since: 0.1.0.0

satisfy Source #

Arguments

:: rep (Char -> Bool)

The predicate that a character must satisfy to be parsed

-> Parser Char

A parser that matches a single character matching the predicate

Attempts to read a single character matching the provided predicate. If it succeeds, the character will be returned and consumed, otherwise the parser will fail having consumed no input.

Since: 0.1.0.0

conditional Source #

Arguments

:: [(rep (a -> Bool), Parser b)]

A list of predicates and their outcomes

-> Parser a

A parser whose result is used to choose an outcome

-> Parser b

A parser who will be executed if no predicates succeed

-> Parser b 

conditional fqs p def first parses p, then it will try each of the predicates in fqs in turn until one of them returns True. The corresponding parser for the first predicate that succeeded is then executes, or if none of the predicates succeeded then the def parser is executed.

Since: 0.1.0.0

Instances

Instances details
ParserOps Defunc Source #

This is used to allow defunctionalised versions of many standard Haskell functions to be used directly as an argument to relevant combinators.

Since: 0.1.0.0

Instance details

Defined in Parsley.ParserOps

Methods

pure :: Defunc a -> Parser a Source #

satisfy :: Defunc (Char -> Bool) -> Parser Char Source #

conditional :: [(Defunc (a -> Bool), Parser b)] -> Parser a -> Parser b -> Parser b Source #

x ~ WQ => ParserOps x Source #

This is the default representation used for user-level functions and values: plain old code.

Since: 0.1.0.0

Instance details

Defined in Parsley.ParserOps

Methods

pure :: x a -> Parser a Source #

satisfy :: x (Char -> Bool) -> Parser Char Source #

conditional :: [(x (a -> Bool), Parser b)] -> Parser a -> Parser b -> Parser b Source #