roundtrip-0.2.0.0: Bidirectional (de-)serialization

Text.Roundtrip.Combinators

Contents

Synopsis

Lexemes

char :: StringSyntax delta => Char -> delta ()Source

char' :: StringSyntax delta => Char -> delta CharSource

string :: StringSyntax delta => String -> delta ()Source

string parses/prints a fixed text and consumes/produces a unit value.

comma :: StringSyntax delta => delta ()Source

dot :: StringSyntax delta => delta ()Source

Repetition

many :: Syntax delta => delta alpha -> delta [alpha]Source

many1 :: Syntax delta => delta alpha -> delta [alpha]Source

sepBy :: Syntax delta => delta alpha -> delta () -> delta [alpha]Source

chainl1 :: Syntax delta => delta alpha -> delta beta -> Iso (alpha, (beta, alpha)) alpha -> delta alphaSource

The chainl1 combinator is used to parse a left-associative chain of infix operators.

Sequencing

(*>) :: Syntax delta => delta () -> delta alpha -> delta alphaSource

This variant of <*> ignores its left result. In contrast to its counterpart derived from the Applicative class, the ignored parts have type `delta ()` rather than `delta beta` because otherwise information relevant for pretty-printing would be lost.

(<*) :: Syntax delta => delta alpha -> delta () -> delta alphaSource

This variant of <*> ignores its right result. In contrast to its counterpart derived from the Applicative class, the ignored parts have type `delta ()` rather than `delta beta` because otherwise information relevant for pretty-printing would be lost.

between :: Syntax delta => delta () -> delta () -> delta alpha -> delta alphaSource

The between function combines *> and <* in the obvious way.

Alternation

(<+>) :: Syntax delta => delta alpha -> delta beta -> delta (Either alpha beta)Source

optional :: Syntax delta => delta alpha -> delta (Maybe alpha)Source

optionalBool :: Syntax delta => delta () -> delta BoolSource

optionalWithDefault :: (Eq alpha, Syntax delta) => alpha -> delta alpha -> delta alphaSource

Whitespace

skipSpace :: StringSyntax delta => delta ()Source

skipSpace marks a position where whitespace is allowed to occur. It accepts arbitrary space while parsing, and produces no space while printing.

sepSpace :: StringSyntax delta => delta ()Source

sepSpace marks a position where whitespace is required to occur. It requires one or more space characters while parsing, and produces a single space character while printing.

optSpace :: StringSyntax delta => delta ()Source

optSpace marks a position where whitespace is desired to occur. It accepts arbitrary space while parsing, and produces a single space character while printing.

XML

xmlElem :: XmlSyntax x => Name -> x a -> x aSource

xmlAttr :: XmlSyntax x => Name -> Iso Text a -> x aSource