Safe Haskell | None |
---|---|
Language | Haskell2010 |
A parse result type for parsers from AST to Haskell types.
Synopsis
- data ParseResult a
- runParseResult :: ParseResult a -> ([PWarning], Either (Maybe Version, NonEmpty PError) a)
- recoverWith :: ParseResult a -> a -> ParseResult a
- parseWarning :: Position -> PWarnType -> String -> ParseResult ()
- parseWarnings :: [PWarning] -> ParseResult ()
- parseFailure :: Position -> String -> ParseResult ()
- parseFatalFailure :: Position -> String -> ParseResult a
- parseFatalFailure' :: ParseResult a
- getCabalSpecVersion :: ParseResult (Maybe Version)
- setCabalSpecVersion :: Maybe Version -> ParseResult ()
- readAndParseFile :: (ByteString -> ParseResult a) -> Verbosity -> FilePath -> IO a
- parseString :: (ByteString -> ParseResult a) -> Verbosity -> String -> ByteString -> IO a
Documentation
data ParseResult a Source #
A monad with failure and accumulating errors and warnings.
Instances
Monad ParseResult # | |
Defined in Distribution.Fields.ParseResult (>>=) :: ParseResult a -> (a -> ParseResult b) -> ParseResult b Source # (>>) :: ParseResult a -> ParseResult b -> ParseResult b Source # return :: a -> ParseResult a Source # | |
Functor ParseResult # | |
Defined in Distribution.Fields.ParseResult fmap :: (a -> b) -> ParseResult a -> ParseResult b Source # (<$) :: a -> ParseResult b -> ParseResult a Source # | |
Applicative ParseResult # | |
Defined in Distribution.Fields.ParseResult pure :: a -> ParseResult a Source # (<*>) :: ParseResult (a -> b) -> ParseResult a -> ParseResult b Source # liftA2 :: (a -> b -> c) -> ParseResult a -> ParseResult b -> ParseResult c Source # (*>) :: ParseResult a -> ParseResult b -> ParseResult b Source # (<*) :: ParseResult a -> ParseResult b -> ParseResult a Source # |
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
parseFatalFailure :: Position -> String -> ParseResult a Source #
Add an fatal error.
parseFatalFailure' :: ParseResult a Source #
A mzero
.
getCabalSpecVersion :: ParseResult (Maybe Version) Source #
Get cabal spec version.
setCabalSpecVersion :: Maybe Version -> ParseResult () Source #
Set cabal spec version.
:: (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.
:: (ByteString -> ParseResult a) | File contents to final value parser |
-> Verbosity | Verbosity level |
-> String | File name |
-> ByteString | |
-> IO a |