ghc-simple-0.1.2.0: Simplified interface to the GHC API.

Safe HaskellNone
LanguageHaskell2010

Language.Haskell.GHC.Simple.Types

Contents

Description

Config, input and output types for the simplified GHC API.

Synopsis

GHC pipeline configuration

class Compile a where Source

Any type we can generate intermediate code for.

Methods

toCode :: ModSummary -> Ghc a Source

Generate some sort of code (or other output) from a Haskell module.

data CompConfig a Source

GHC pipeline configuration, parameterized over the intermediate code produced by the pipeline.

defaultConfig :: Compile a => CompConfig a Source

Default configuration.

cfgGhcFlags :: CompConfig a -> [String] Source

GHC command line dynamic flags to control the Haskell to STG compilation pipeline. For instance, passing ["-O2", "-DHELLO"] here is equivalent to passing -O2 -DHELLO to the ghc binary.

Note that flags set here are overridden by any changes to DynFlags performed by cfgUpdateDynFlags, and that '--make' mode is always in effect.

Default: []

cfgUseTargetsFromFlags :: CompConfig a -> Bool Source

If file or module names are found among the cfgGhcFlags, should they be used as targets, in addition to any targets given by other arguments to withStg et al?

Default: True

cfgUpdateDynFlags :: CompConfig a -> DynFlags -> DynFlags Source

Modify the dynamic flags governing the compilation process. Changes made here take precedence over any flags passed through cfgGhcFlags.

Default: id

cfgGhcLibDir :: CompConfig a -> Maybe FilePath Source

Path to GHC's library directory. If Nothing, the library directory of the system's default GHC compiler will be used.

Default: Nothing

cfgUseGhcErrorLogger :: CompConfig a -> Bool Source

Use GHC's standard logger to log errors and warnings to the command line? Errors and warnings are always collected and returned, regardless of the value of this setting.

Output other than errors and warnings (dumps, etc.) are logged using the standard logger by default. For finer control over logging behavior, you should override log_action in cfgUpdateDynFlags.

Default: False

cfgCustomPrimIface :: CompConfig a -> Maybe (PrimOp -> PrimOpInfo, PrimOp -> Arity -> StrictSig) Source

Use a custom interface for GHC.Prim. This is useful if you want to, for instance, compile to a 32 bit target architecture on a 64 bit host.

For more information, see Language.Haskell.GHC.Simple.PrimIface.

Default: Nothing

cfgGhcPipeline :: CompConfig a -> ModSummary -> Ghc a Source

Use a custom GHC pipeline to generate intermediate code. Useful if the provided instances for [StgBinding] etc. don't quite do what you want them to. See Language.Haskell.GHC.Simple.Impl for more information about custom pipelines.

Default: toCode

Compilation results and errors

data CompiledModule a Source

Compiler output and metadata for a given module.

Constructors

CompiledModule 

Fields

modSummary :: ModSummary

ModSummary for the module, as given by GHC.

modName :: String

String representation of the module's name, not qualified with a package key. ModuleName representation can be obtained from the module's stgModSummary.

modPackageKey :: String

String representation of the module's package key. PackageKey representation can be obtained from the module's stgModSummary.

modIsTarget :: Bool

Is this module a compilation target (as opposed to a dependency of one)?

modSourceIsHsBoot :: Bool

Was the module compiler from a hs-boot file?

modSourceFile :: Maybe FilePath

The Haskell source the module was compiled from, if any.

modInterfaceFile :: FilePath

Interface file corresponding to this module.

modCompiledModule :: a

Module data generated by compilation; usually bindings of some kind.

data CompResult a Source

Result of a compilation.

Constructors

Success 

Fields

compResult :: a

Result of the compilation.

compWarnings :: [Warning]

Warnings that occurred during compilation.

compDynFlags :: DynFlags

Initial DynFlags used by this compilation, collected from Config data.

Failure 

Fields

compErrors :: [Error]

Errors that occurred during compilation.

compWarnings :: [Warning]

Warnings that occurred during compilation.

data Error Source

A GHC error message.

Constructors

Error 

Fields

errorSpan :: SrcSpan

Where did the error occur?

errorMessage :: String

Description of the error.

errorExtraInfo :: String

More verbose description of the error.

data Warning Source

A GHC warning.

Constructors

Warning 

Fields

warnSpan :: SrcSpan

Where did the warning occur?

warnMessage :: String

What was the warning about?

compSuccess :: CompResult a -> Bool Source

Does the given CompResult represent a successful compilation?