boomerang-1.3.3: Library for invertible parsing and printing

Safe HaskellNone

Text.Boomerang.String

Contents

Description

a PrinterParser library for working with a String

Synopsis

Types

Combinators

alpha :: StringPrinterParser r (Char :- r)Source

matches alphabetic Unicode characters (lower-case, upper-case and title-case letters, plus letters of caseless scripts and modifiers letters). (Uses isAlpha)

anyChar :: StringPrinterParser r (Char :- r)Source

any character

char :: Char -> StringPrinterParser r (Char :- r)Source

matches the specified character

digit :: StringPrinterParser r (Char :- r)Source

ascii digits '0'..'9'

int :: StringPrinterParser r (Int :- r)Source

matches an Int

lit :: String -> StringPrinterParser r rSource

a constant string

satisfy :: (Char -> Bool) -> StringPrinterParser r (Char :- r)Source

statisfy a Char predicate

space :: StringPrinterParser r (Char :- r)Source

matches white-space characters in the Latin-1 range. (Uses isSpace)

Running the PrinterParser

isComplete :: String -> BoolSource

Predicate to test if we have parsed all the strings. Typically used as argument to parse1

see also: parseStrings

parseString :: StringPrinterParser () (r :- ()) -> String -> Either StringError rSource

run the parser

Returns the first complete parse or a parse error.

 parseString (rUnit . lit "foo") ["foo"]

unparseString :: StringPrinterParser () (r :- ()) -> r -> Maybe StringSource

run the printer

 unparseString (rUnit . lit "foo") ()