HIE.Bios.Ghc.Load

hie-bios-0.14.0: Set up a GHC API session

Safe Haskell | None
Language | Haskell2010

HIE.Bios.Ghc.Load

Description

Convenience functions for loading a file into a GHC API session

Synopsis

- data Log
  - = LogLoaded FilePath FilePath
  - | LogTypechecked [TypecheckedModule]
  - | LogInitPlugins Int [ModuleName]
  - | LogSetTargets [(FilePath, FilePath)]
  - | LogModGraph ModuleGraph
- get_fp :: TypecheckedModule -> Maybe FilePath
- loadFileWithMessage :: GhcMonad m => LogAction IO (WithSeverity Log) -> Maybe Messager -> (FilePath, FilePath) -> m (Maybe TypecheckedModule, [TypecheckedModule])
- loadFile :: GhcMonad m => LogAction IO (WithSeverity Log) -> (FilePath, FilePath) -> m (Maybe TypecheckedModule, [TypecheckedModule])
- setTargetFiles :: GhcMonad m => LogAction IO (WithSeverity Log) -> [(FilePath, FilePath)] -> m ()
- msTargetIs :: ModSummary -> Target -> Bool
- updateTime :: MonadIO m => [Target] -> ModuleGraph -> m ModuleGraph
- setTargetFilesWithMessage :: GhcMonad m => LogAction IO (WithSeverity Log) -> Maybe Messager -> [(FilePath, FilePath)] -> m ()
- collectASTs :: GhcMonad m => LogAction IO (WithSeverity Log) -> m a -> m (a, [TypecheckedModule])
- astHook :: LogAction IO (WithSeverity Log) -> IORef [TypecheckedModule] -> ModSummary -> Hsc FrontendResult
- initializePluginsGhc :: GhcMonad m => LogAction IO (WithSeverity Log) -> ModSummary -> m ModSummary
- ghcInHsc :: Ghc a -> Hsc a
- guessTargetMapped :: GhcMonad m => (FilePath, FilePath) -> m Target
- setTargetFilename :: FilePath -> Target -> Target

# Documentation

data Log #

Constructors

LogLoaded FilePath FilePath |
LogTypechecked [TypecheckedModule] |
LogInitPlugins Int [ModuleName] |
LogSetTargets [(FilePath, FilePath)] |
LogModGraph ModuleGraph |

#### Instances

Instances details

Pretty Log # |
Instance details Defined in HIE.Bios.Ghc.Load Methods pretty :: Log -> Doc ann # prettyList :: [Log] -> Doc ann #

get_fp :: TypecheckedModule -> Maybe FilePath #

loadFileWithMessage #

Arguments

:: GhcMonad m |
=> LogAction IO (WithSeverity Log) |
-> Maybe Messager | Optional messager hook to log messages produced by GHC.
-> (FilePath, FilePath) | Target file to load.
-> m (Maybe TypecheckedModule, [TypecheckedModule]) | Typechecked module and modules that had to be loaded for the target.

Load a target into the GHC session.

The target is represented as a tuple. The tuple consists of the original filename and another file that contains the actual source code to compile.

The optional messager can be used to log diagnostics, warnings or errors that occurred during loading the target.

If the loading succeeds, the typechecked module is returned together with all the typechecked modules that had to be loaded in order to typecheck the given target.

loadFile #

Arguments

:: GhcMonad m |
=> LogAction IO (WithSeverity Log) |
-> (FilePath, FilePath) | Target file to load.
-> m (Maybe TypecheckedModule, [TypecheckedModule]) | Typechecked module and modules that had to be loaded for the target.

Load a target into the GHC session with the default messager which outputs updates in the same format as normal GHC.

The target is represented as a tuple. The tuple consists of the original filename and another file that contains the actual source code to compile.

If the message should configured, use `loadFileWithMessage`.

If the loading succeeds, the typechecked module is returned together with all the typechecked modules that had to be loaded in order to typecheck the given target.

setTargetFiles :: GhcMonad m => LogAction IO (WithSeverity Log) -> [(FilePath, FilePath)] -> m () #

Set the files as targets and load them. This will reset GHC's targets so only the modules you set as targets and its dependencies will be loaded or reloaded. Produced diagnostics will be printed similar to the normal output of GHC. To configure this, use `setTargetFilesWithMessage`.

msTargetIs :: ModSummary -> Target -> Bool #

updateTime :: MonadIO m => [Target] -> ModuleGraph -> m ModuleGraph #

We bump the times for any ModSummary's that are Targets, to fool the recompilation checker so that we can get the typechecked modules

setTargetFilesWithMessage :: GhcMonad m => LogAction IO (WithSeverity Log) -> Maybe Messager -> [(FilePath, FilePath)] -> m () #

Set the files as targets and load them. This will reset GHC's targets so only the modules you set as targets and its dependencies will be loaded or reloaded.

collectASTs :: GhcMonad m => LogAction IO (WithSeverity Log) -> m a -> m (a, [TypecheckedModule]) #

Add a hook to record the contents of any `TypecheckedModule`s which are produced during compilation.

astHook :: LogAction IO (WithSeverity Log) -> IORef [TypecheckedModule] -> ModSummary -> Hsc FrontendResult #

This hook overwrites the default frontend action of GHC.

initializePluginsGhc :: GhcMonad m => LogAction IO (WithSeverity Log) -> ModSummary -> m ModSummary #

ghcInHsc :: Ghc a -> Hsc a #

guessTargetMapped :: GhcMonad m => (FilePath, FilePath) -> m Target #

A variant of `guessTarget` which after guessing the target for a filepath, overwrites the target file to be a temporary file.

setTargetFilename :: FilePath -> Target -> Target #