| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
CabalFix.FlatParse
Description
Various flatparse helpers and combinators.
Synopsis
- data ParserWarning
- runParserMaybe :: Parser e a -> ByteString -> Maybe a
- runParserEither :: IsString e => Parser e a -> ByteString -> Either e a
- runParserWarn :: Parser ByteString a -> ByteString -> These ParserWarning a
- runParser_ :: Parser String a -> ByteString -> a
- runParser__ :: Parser String a -> ByteString -> a
- runParser :: Parser e a -> ByteString -> Result e a
- type Parser = ParserT PureMode
- data Result e a
- = OK a !ByteString
- | Fail
- | Err !e
- depP :: Parser e (ByteString, ByteString)
- versionP :: Parser e [Int]
- versionInts :: ByteString -> [Int]
- untilP :: Char -> Parser e ByteString
- nota :: Char -> Parser e ByteString
- ws_ :: Parser e ()
- ws :: Parser e Char
Parsing
data ParserWarning Source #
Constructors
| ParserLeftover ByteString | |
| ParserError ByteString | |
| ParserUncaught |
Instances
runParserMaybe :: Parser e a -> ByteString -> Maybe a Source #
runParserEither :: IsString e => Parser e a -> ByteString -> Either e a Source #
runParserWarn :: Parser ByteString a -> ByteString -> These ParserWarning a Source #
Run parser, returning leftovers and errors as ParserWarnings.
runParser_ :: Parser String a -> ByteString -> a Source #
Run parser, discards leftovers & throws an error on failure.
>>>runParser_ ws " "' '
>>>runParser_ ws "x"*** Exception: uncaught parse error ...
runParser__ :: Parser String a -> ByteString -> a Source #
Run parser, errors on leftovers & failure.
>>>runParser_ ws " "' '
>>>runParser_ ws "x"*** Exception: uncaught parse error ...
Flatparse re-exports
runParser :: Parser e a -> ByteString -> Result e a #
Run a parser.
Higher-level boxed data type for parsing results.
Constructors
| OK a !ByteString | Contains return value and unconsumed input. |
| Fail | Recoverable-by-default failure. |
| Err !e | Unrecoverble-by-default error. |
Parsers
depP :: Parser e (ByteString, ByteString) Source #
Parse a dependency line into a name, range tuple. Consumes any commas it finds.
versionInts :: ByteString -> [Int] Source #
partial running of versionP
>>>versionInts "0.6.10.0"[0,6,10,0]
untilP :: Char -> Parser e ByteString Source #
parse whilst not a specific character, then consume the character.
>>>runParser (untilP 'x') "abcxyz"OK "abc" "yz"
nota :: Char -> Parser e ByteString Source #
Parse whilst not a specific character
>>>runParser (nota 'x') "abcxyz"OK "abc" "xyz"
Consume whitespace.
>>>runParser ws_ " \nx"OK () "x"
>>>runParser ws_ "x"OK () "x"