Safe Haskell | None |
---|
a PrinterParser
library for working with '[Text]'
- type TextsError = ParserError MajorMinorPos
- (</>) :: PrinterParser TextsError [Text] b c -> PrinterParser TextsError [Text] a b -> PrinterParser TextsError [Text] a c
- alpha :: PrinterParser TextsError [Text] r (Char :- r)
- anyChar :: PrinterParser TextsError [Text] r (Char :- r)
- anyText :: PrinterParser TextsError [Text] r (Text :- r)
- char :: Char -> PrinterParser TextsError [Text] r (Char :- r)
- digit :: PrinterParser TextsError [Text] r (Char :- r)
- digits :: PrinterParser TextsError [Text] r (Text :- r)
- signed :: PrinterParser TextsError [Text] a (Text :- r) -> PrinterParser TextsError [Text] a (Text :- r)
- eos :: PrinterParser TextsError [Text] r r
- integral :: (Integral a, Show a) => PrinterParser TextsError [Text] r (a :- r)
- int :: PrinterParser TextsError [Text] r (Int :- r)
- integer :: PrinterParser TextsError [Text] r (Integer :- r)
- lit :: Text -> PrinterParser TextsError [Text] r r
- readshow :: (Read a, Show a) => PrinterParser TextsError [Text] r (a :- r)
- satisfy :: (Char -> Bool) -> PrinterParser TextsError [Text] r (Char :- r)
- satisfyStr :: (Text -> Bool) -> PrinterParser TextsError [Text] r (Text :- r)
- space :: PrinterParser TextsError [Text] r (Char :- r)
- rTextCons :: PrinterParser e tok (Char :- (Text :- r)) (Text :- r)
- rEmpty :: PrinterParser e [Text] r (Text :- r)
- rText :: PrinterParser e [Text] r (Char :- r) -> PrinterParser e [Text] r (Text :- r)
- rText1 :: PrinterParser e [Text] r (Char :- r) -> PrinterParser e [Text] r (Text :- r)
- isComplete :: [Text] -> Bool
- parseTexts :: PrinterParser TextsError [Text] () (r :- ()) -> [Text] -> Either TextsError r
- unparseTexts :: PrinterParser e [Text] () (r :- ()) -> r -> Maybe [Text]
Types
Combinators
(</>) :: PrinterParser TextsError [Text] b c -> PrinterParser TextsError [Text] a b -> PrinterParser TextsError [Text] a cSource
equivalent to f . eos . g
alpha :: PrinterParser TextsError [Text] 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 :: PrinterParser TextsError [Text] r (Char :- r)Source
any character
anyText :: PrinterParser TextsError [Text] r (Text :- r)Source
char :: Char -> PrinterParser TextsError [Text] r (Char :- r)Source
matches the specified character
digit :: PrinterParser TextsError [Text] r (Char :- r)Source
ascii digits '0'..'9'
digits :: PrinterParser TextsError [Text] r (Text :- r)Source
a sequence of digits
signed :: PrinterParser TextsError [Text] a (Text :- r) -> PrinterParser TextsError [Text] a (Text :- r)Source
eos :: PrinterParser TextsError [Text] r rSource
end of string
integral :: (Integral a, Show a) => PrinterParser TextsError [Text] r (a :- r)Source
matches an Integral
value
Note that the combinator (rPair . integral . integral)
is ill-defined because the parse canwell. not tell where it is supposed to split the sequence of digits to produced two ints.
int :: PrinterParser TextsError [Text] r (Int :- r)Source
matches an Int
Note that the combinator (rPair . int . int)
is ill-defined because the parse canwell. not tell where it is supposed to split the sequence of digits to produced two ints.
integer :: PrinterParser TextsError [Text] r (Integer :- r)Source
matches an Integer
Note that the combinator (rPair . integer . integer)
is ill-defined because the parse can not tell where it is supposed to split the sequence of digits to produced two ints.
lit :: Text -> PrinterParser TextsError [Text] r rSource
a constant string
readshow :: (Read a, Show a) => PrinterParser TextsError [Text] r (a :- r)Source
lift 'Read'/'Show' to a PrinterParser
There are a few restrictions here:
satisfy :: (Char -> Bool) -> PrinterParser TextsError [Text] r (Char :- r)Source
statisfy a Char
predicate
satisfyStr :: (Text -> Bool) -> PrinterParser TextsError [Text] r (Text :- r)Source
space :: PrinterParser TextsError [Text] r (Char :- r)Source
matches white-space characters in the Latin-1 range. (Uses isSpace
)
rTextCons :: PrinterParser e tok (Char :- (Text :- r)) (Text :- r)Source
the first character of a Text
rText :: PrinterParser e [Text] r (Char :- r) -> PrinterParser e [Text] r (Text :- r)Source
rText1 :: PrinterParser e [Text] r (Char :- r) -> PrinterParser e [Text] r (Text :- r)Source
Running the PrinterParser
isComplete :: [Text] -> BoolSource
Predicate to test if we have parsed all the Texts.
Typically used as argument to parse1
see also: parseTexts
parseTexts :: PrinterParser TextsError [Text] () (r :- ()) -> [Text] -> Either TextsError rSource
run the parser
Returns the first complete parse or a parse error.
parseTexts (rUnit . lit "foo") ["foo"]
unparseTexts :: PrinterParser e [Text] () (r :- ()) -> r -> Maybe [Text]Source
run the printer
unparseTexts (rUnit . lit "foo") ()