Distribution.Parsec.ParseResult

Cabal-2.1.0.0: A framework for packaging Haskell software

Safe Haskell | None
Language | Haskell2010

Distribution.Parsec.ParseResult

Description

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

Synopsis

- data ParseResult a
- runParseResult :: ParseResult a -> ([PWarning], [PError], Maybe 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

# Documentation

data ParseResult a Source #

A monad with failure and accumulating errors and warnings.

Instances

Monad ParseResult # |
Instance details Methods (>>=) :: ParseResult a -> (a -> ParseResult b) -> ParseResult b Source # (>>) :: ParseResult a -> ParseResult b -> ParseResult b Source # return :: a -> ParseResult a Source # fail :: String -> ParseResult a Source #
Functor ParseResult # |
Instance details Methods fmap :: (a -> b) -> ParseResult a -> ParseResult b Source # (<$) :: a -> ParseResult b -> ParseResult a Source #
Applicative ParseResult # |
Instance details Methods 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], [PError], Maybe a) Source #

Destruct a `ParseResult` into the emitted warnings and errors, and possibly the final result if there were no errors.

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`.