Cabal-2.4.0.0: A framework for packaging Haskell software

Safe HaskellNone
LanguageHaskell2010

Distribution.Parsec.ParseResult

Description

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

Synopsis

Documentation

data ParseResult a #

A monad with failure and accumulating errors and warnings.

Instances
Monad ParseResult # 
Instance details

Defined in Distribution.Parsec.ParseResult

Functor ParseResult # 
Instance details

Defined in Distribution.Parsec.ParseResult

Methods

fmap :: (a -> b) -> ParseResult a -> ParseResult b #

(<$) :: a -> ParseResult b -> ParseResult a #

Applicative ParseResult # 
Instance details

Defined in Distribution.Parsec.ParseResult

Methods

pure :: a -> ParseResult a #

(<*>) :: ParseResult (a -> b) -> ParseResult a -> ParseResult b #

liftA2 :: (a -> b -> c) -> ParseResult a -> ParseResult b -> ParseResult c #

(*>) :: ParseResult a -> ParseResult b -> ParseResult b #

(<*) :: ParseResult a -> ParseResult b -> ParseResult a #

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

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 #

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 () #

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

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

Add multiple warnings at once.

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

Add an error, but not fail the parser yet.

For fatal failure use parseFatalFailure

parseFatalFailure :: Position -> String -> ParseResult a #

Add an fatal error.

getCabalSpecVersion :: ParseResult (Maybe Version) #

Get cabal spec version.

setCabalSpecVersion :: Maybe Version -> ParseResult () #

Set cabal spec version.

readAndParseFile #

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 #

Arguments

:: (ByteString -> ParseResult a)

File contents to final value parser

-> Verbosity

Verbosity level

-> String

File name

-> ByteString 
-> IO a