ghc-8.0.0.20160204: The GHC API

Safe HaskellNone
LanguageHaskell2010

ErrUtils

Contents

Synopsis

Basic types

data Validity

Constructors

IsValid

Everything is fine

NotValid MsgDoc

A problem, and some indication of why

allValid :: [Validity] -> Validity

If they aren't all valid, return the first

data Severity

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

data ErrDoc

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

Formatting

Construction

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

A short (one-line) error message

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

Variant that doesn't care about qualified/unqualified names

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

A long (multi-line) error message

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

A short (one-line) error message

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

Variant that doesn't care about qualified/unqualified names

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

A long (multi-line) error message

Utilities

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

Dump files

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

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

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

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

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

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

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

Like logInfo but with SevOutput rather then SevInfo

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