Cabal-3.2.1.0: A framework for packaging Haskell software
Safe Haskell None
Language Haskell2010

Distribution.Fields.ParseResult

Description

A parse result type for parsers from AST to Haskell types.

Synopsis

Documentation

runParseResult :: ParseResult a -> ([ PWarning ], Either ( Maybe Version , NonEmpty PError ) a) Source #

Destruct a ParseResult into the emitted warnings and either a successful value or list of errors and possibly recovered a spec-version declaration.

recoverWith :: ParseResult a -> a -> ParseResult a Source #

Recover the parse result, so we can proceed parsing. runParseResult will still result in Nothing , if there are recorded errors.

parseWarning :: Position -> PWarnType -> String -> ParseResult () Source #

Add a warning. This doesn't fail the parsing process.

parseWarnings :: [ PWarning ] -> ParseResult () Source #

Add multiple warnings at once.

parseFailure :: Position -> String -> ParseResult () Source #

Add an error, but not fail the parser yet.

For fatal failure use parseFatalFailure

readAndParseFile Source #

Arguments

:: ( ByteString -> ParseResult a)

File contents to final value parser

-> Verbosity

Verbosity level

-> FilePath

File to read

-> IO a

Helper combinator to do parsing plumbing for files.

Given a parser and a filename, return the parse of the file, after checking if the file exists.

Argument order is chosen to encourage partial application.

parseString Source #

Arguments

:: ( ByteString -> ParseResult a)

File contents to final value parser

-> Verbosity

Verbosity level

-> String

File name

-> ByteString
-> IO a