ErrUtils

ghc-8.0.0.20160204: The GHC API

Safe Haskell | None
Language | Haskell2010

ErrUtils

Contents

- Basic types
- Messages
  - Formatting
  - Construction
- Utilities
- Dump files
- Issuing messages during compilation

Synopsis

- data Validity
  - = IsValid
  - | NotValid MsgDoc
- andValid :: Validity -> Validity -> Validity
- allValid :: [Validity] -> Validity
- isValid :: Validity -> Bool
- getInvalids :: [Validity] -> [MsgDoc]
- data Severity
  - = SevOutput
  - | SevFatal
  - | SevInteractive
  - | SevDump
  - | SevInfo
  - | SevWarning
  - | SevError
- type MsgDoc = SDoc
- data ErrMsg
- data ErrDoc
- errDoc :: [MsgDoc] -> [MsgDoc] -> [MsgDoc] -> ErrDoc
- type WarnMsg = ErrMsg
- type Messages = (WarningMessages, ErrorMessages)
- type ErrorMessages = Bag ErrMsg
- type WarningMessages = Bag WarnMsg
- unionMessages :: Messages -> Messages -> Messages
- errMsgSpan :: ErrMsg -> SrcSpan
- errMsgContext :: ErrMsg -> PrintUnqualified
- errorsFound :: DynFlags -> Messages -> Bool
- isEmptyMessages :: Messages -> Bool
- pprMessageBag :: Bag MsgDoc -> SDoc
- pprErrMsgBagWithLoc :: Bag ErrMsg -> [SDoc]
- pprLocErrMsg :: ErrMsg -> SDoc
- printBagOfErrors :: DynFlags -> Bag ErrMsg -> IO ()
- emptyMessages :: Messages
- mkLocMessage :: Severity -> SrcSpan -> MsgDoc -> MsgDoc
- makeIntoWarning :: ErrMsg -> ErrMsg
- mkErrMsg :: DynFlags -> SrcSpan -> PrintUnqualified -> MsgDoc -> ErrMsg
- mkPlainErrMsg :: DynFlags -> SrcSpan -> MsgDoc -> ErrMsg
- mkErrDoc :: DynFlags -> SrcSpan -> PrintUnqualified -> ErrDoc -> ErrMsg
- mkLongErrMsg :: DynFlags -> SrcSpan -> PrintUnqualified -> MsgDoc -> MsgDoc -> ErrMsg
- mkWarnMsg :: DynFlags -> SrcSpan -> PrintUnqualified -> MsgDoc -> ErrMsg
- mkPlainWarnMsg :: DynFlags -> SrcSpan -> MsgDoc -> ErrMsg
- warnIsErrorMsg :: DynFlags -> ErrMsg
- mkLongWarnMsg :: DynFlags -> SrcSpan -> PrintUnqualified -> MsgDoc -> MsgDoc -> ErrMsg
- doIfSet :: Bool -> IO () -> IO ()
- doIfSet_dyn :: DynFlags -> GeneralFlag -> IO () -> IO ()
- dumpIfSet :: DynFlags -> Bool -> String -> SDoc -> IO ()
- dumpIfSet_dyn :: DynFlags -> DumpFlag -> String -> SDoc -> IO ()
- dumpIfSet_dyn_printer :: PrintUnqualified -> DynFlags -> DumpFlag -> SDoc -> IO ()
- mkDumpDoc :: String -> SDoc -> SDoc
- dumpSDoc :: DynFlags -> PrintUnqualified -> DumpFlag -> String -> SDoc -> IO ()
- putMsg :: DynFlags -> MsgDoc -> IO ()
- printInfoForUser :: DynFlags -> PrintUnqualified -> MsgDoc -> IO ()
- printOutputForUser :: DynFlags -> PrintUnqualified -> MsgDoc -> IO ()
- logInfo :: DynFlags -> PprStyle -> MsgDoc -> IO ()
- logOutput :: DynFlags -> PprStyle -> MsgDoc -> IO ()
- errorMsg :: DynFlags -> MsgDoc -> IO ()
- warningMsg :: DynFlags -> MsgDoc -> IO ()
- fatalErrorMsg :: DynFlags -> MsgDoc -> IO ()
- fatalErrorMsg' :: LogAction -> DynFlags -> MsgDoc -> IO ()
- fatalErrorMsg'' :: FatalMessager -> String -> IO ()
- compilationProgressMsg :: DynFlags -> String -> IO ()
- showPass :: DynFlags -> String -> IO ()
- debugTraceMsg :: DynFlags -> Int -> MsgDoc -> IO ()
- ghcExit :: DynFlags -> Int -> IO ()
- prettyPrintGhcErrors :: ExceptionMonad m => DynFlags -> m a -> m a

# Basic types

data Validity Source

Constructors

IsValid | Everything is fine
NotValid MsgDoc | A problem, and some indication of why

andValid :: Validity -> Validity -> Validity Source

allValid :: [Validity] -> Validity Source

If they aren't all valid, return the first

isValid :: Validity -> Bool Source

getInvalids :: [Validity] -> [MsgDoc] Source

data Severity Source

Constructors

SevOutput |
SevFatal |
SevInteractive |
SevDump | Log messagse intended for compiler developers No filelinecolumn stuff
SevInfo | Log messages intended for end users. No filelinecolumn stuff.
SevWarning |
SevError | SevWarning and SevError are used for warnings and errors o The message has a filelinecolumn heading, plus "warning:" or "error:", added by mkLocMessags o Output is intended for end users

# Messages

type MsgDoc = SDoc Source

data ErrMsg Source

Instances

Show ErrMsg |
Methods showsPrec :: Int -> ErrMsg -> ShowS Source show :: ErrMsg -> String Source showList :: [ErrMsg] -> ShowS Source

data ErrDoc Source

Categorise error msgs by their importance. This is so each section can be rendered visually distinct. See Note [Error report] for where these come from.

errDoc :: [MsgDoc] -> [MsgDoc] -> [MsgDoc] -> ErrDoc Source

type WarnMsg = ErrMsg Source

type Messages = (WarningMessages, ErrorMessages) Source

type ErrorMessages = Bag ErrMsg Source

type WarningMessages = Bag WarnMsg Source

unionMessages :: Messages -> Messages -> Messages Source

errMsgSpan :: ErrMsg -> SrcSpan Source

errMsgContext :: ErrMsg -> PrintUnqualified Source

errorsFound :: DynFlags -> Messages -> Bool Source

isEmptyMessages :: Messages -> Bool Source

## Formatting

pprMessageBag :: Bag MsgDoc -> SDoc Source

pprErrMsgBagWithLoc :: Bag ErrMsg -> [SDoc] Source

pprLocErrMsg :: ErrMsg -> SDoc Source

printBagOfErrors :: DynFlags -> Bag ErrMsg -> IO () Source

## Construction

emptyMessages :: Messages Source

mkLocMessage :: Severity -> SrcSpan -> MsgDoc -> MsgDoc Source

makeIntoWarning :: ErrMsg -> ErrMsg Source

mkErrMsg :: DynFlags -> SrcSpan -> PrintUnqualified -> MsgDoc -> ErrMsg Source

A short (one-line) error message

mkPlainErrMsg :: DynFlags -> SrcSpan -> MsgDoc -> ErrMsg Source

Variant that doesn't care about qualified/unqualified names

mkErrDoc :: DynFlags -> SrcSpan -> PrintUnqualified -> ErrDoc -> ErrMsg Source

mkLongErrMsg :: DynFlags -> SrcSpan -> PrintUnqualified -> MsgDoc -> MsgDoc -> ErrMsg Source

A long (multi-line) error message

mkWarnMsg :: DynFlags -> SrcSpan -> PrintUnqualified -> MsgDoc -> ErrMsg Source

A short (one-line) error message

mkPlainWarnMsg :: DynFlags -> SrcSpan -> MsgDoc -> ErrMsg Source

Variant that doesn't care about qualified/unqualified names

warnIsErrorMsg :: DynFlags -> ErrMsg Source

mkLongWarnMsg :: DynFlags -> SrcSpan -> PrintUnqualified -> MsgDoc -> MsgDoc -> ErrMsg Source

A long (multi-line) error message

# Utilities

doIfSet :: Bool -> IO () -> IO () Source

doIfSet_dyn :: DynFlags -> GeneralFlag -> IO () -> IO () Source

# Dump files

dumpIfSet :: DynFlags -> Bool -> String -> SDoc -> IO () Source

dumpIfSet_dyn :: DynFlags -> DumpFlag -> String -> SDoc -> IO () Source

a wrapper around `dumpSDoc`. First check whether the dump flag is set Do nothing if it is unset

dumpIfSet_dyn_printer :: PrintUnqualified -> DynFlags -> DumpFlag -> SDoc -> IO () Source

a wrapper around `dumpSDoc`. First check whether the dump flag is set Do nothing if it is unset

Unlike `dumpIfSet_dyn`, has a printer argument but no header argument

mkDumpDoc :: String -> SDoc -> SDoc Source

dumpSDoc :: DynFlags -> PrintUnqualified -> DumpFlag -> String -> SDoc -> IO () Source

Write out a dump. If --dump-to-file is set then this goes to a file. otherwise emit to stdout.

When `hdr` is empty, we print in a more compact format (no separators and blank lines)

The `DumpFlag` is used only to choose the filename to use if `--dump-to-file` is used; it is not used to decide whether to dump the output

# Issuing messages during compilation

putMsg :: DynFlags -> MsgDoc -> IO () Source

printInfoForUser :: DynFlags -> PrintUnqualified -> MsgDoc -> IO () Source

printOutputForUser :: DynFlags -> PrintUnqualified -> MsgDoc -> IO () Source

logInfo :: DynFlags -> PprStyle -> MsgDoc -> IO () Source

logOutput :: DynFlags -> PprStyle -> MsgDoc -> IO () Source

Like `logInfo` but with `SevOutput` rather then `SevInfo`

errorMsg :: DynFlags -> MsgDoc -> IO () Source

warningMsg :: DynFlags -> MsgDoc -> IO () Source

fatalErrorMsg :: DynFlags -> MsgDoc -> IO () Source

fatalErrorMsg' :: LogAction -> DynFlags -> MsgDoc -> IO () Source

fatalErrorMsg'' :: FatalMessager -> String -> IO () Source

compilationProgressMsg :: DynFlags -> String -> IO () Source

showPass :: DynFlags -> String -> IO () Source

debugTraceMsg :: DynFlags -> Int -> MsgDoc -> IO () Source

ghcExit :: DynFlags -> Int -> IO () Source

prettyPrintGhcErrors :: ExceptionMonad m => DynFlags -> m a -> m a Source