cabal-fix-0.0.0.2: Fix for cabal files.
Safe HaskellSafe-Inferred
LanguageGHC2021

CabalFix.FlatParse

Description

Various flatparse helpers and combinators.

Synopsis

Parsing

data ParserWarning Source #

Warnings covering leftovers, Errs and Fail

Instances

Instances details
Generic ParserWarning Source # 
Instance details

Defined in CabalFix.FlatParse

Associated Types

type Rep ParserWarning :: Type -> Type #

Show ParserWarning Source # 
Instance details

Defined in CabalFix.FlatParse

Eq ParserWarning Source # 
Instance details

Defined in CabalFix.FlatParse

Ord ParserWarning Source # 
Instance details

Defined in CabalFix.FlatParse

type Rep ParserWarning Source # 
Instance details

Defined in CabalFix.FlatParse

type Rep ParserWarning = D1 ('MetaData "ParserWarning" "CabalFix.FlatParse" "cabal-fix-0.0.0.2-GueGPKFkv7p1skPCP5Ed4H" 'False) (C1 ('MetaCons "ParserLeftover" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)) :+: (C1 ('MetaCons "ParserError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)) :+: C1 ('MetaCons "ParserUncaught" 'PrefixI 'False) (U1 :: Type -> Type)))

runParserMaybe :: Parser e a -> ByteString -> Maybe a Source #

Run a Parser, throwing away leftovers. Nothing on Fail or Err.

runParserEither :: IsString e => Parser e a -> ByteString -> Either e a Source #

Run a Parser, throwing away leftovers. Returns Left on Fail or Err.

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.

type Parser = ParserT PureMode #

The type of pure parsers.

data Result e a #

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.

Instances

Instances details
Functor (Result e) 
Instance details

Defined in FlatParse.Basic

Methods

fmap :: (a -> b) -> Result e a -> Result e b #

(<$) :: a -> Result e b -> Result e a #

(Show a, Show e) => Show (Result e a) 
Instance details

Defined in FlatParse.Basic

Methods

showsPrec :: Int -> Result e a -> ShowS #

show :: Result e a -> String #

showList :: [Result e a] -> ShowS #

Parsers

depP :: Parser e (ByteString, ByteString) Source #

Parse a dependency line into a name, range tuple. Consumes any commas it finds.

versionP :: Parser e [Int] Source #

Parse a version bytestring ti an int list.

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"

ws_ :: Parser e () Source #

Consume whitespace.

>>> runParser ws_ " \nx"
OK () "x"
>>> runParser ws_ "x"
OK () "x"

ws :: Parser e Char Source #

single whitespace

>>> runParser ws " \nx"
OK ' ' "\nx"