Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
The HIE Bios
Provides an abstraction over the GHC Api to initialise a GHC session and loading modules in a project.
Defines the `hie.yaml` file specification. This is used to explicitly configure how a project should be built by GHC.
Synopsis
- data Cradle a = Cradle {}
- data CradleLoadResult r
- data CradleError = CradleError {}
- findCradle :: FilePath -> IO (Maybe FilePath)
- loadCradle :: LogAction IO (WithSeverity Log) -> FilePath -> IO (Cradle Void)
- loadImplicitCradle :: Show a => LogAction IO (WithSeverity Log) -> FilePath -> IO (Cradle a)
- defaultCradle :: LogAction IO (WithSeverity Log) -> FilePath -> Cradle a
- data ComponentOptions = ComponentOptions {}
- getCompilerOptions :: FilePath -> [FilePath] -> Cradle a -> IO (CradleLoadResult ComponentOptions)
- initSession :: GhcMonad m => ComponentOptions -> m [Target]
- loadFile :: GhcMonad m => LogAction IO (WithSeverity Log) -> (FilePath, FilePath) -> m (Maybe TypecheckedModule, [TypecheckedModule])
Find and load a Cradle
The environment of a single Cradle
.
A Cradle
is a unit for the respective build-system.
It contains the root directory of the Cradle
, the name of
the Cradle
(for debugging purposes), and knows how to set up
a GHC session that is able to compile files that are part of this Cradle
.
A Cradle
may be a single unit in the "cabal-install" context, or
the whole package, comparable to how "stack" works.
Cradle | |
|
data CradleLoadResult r Source #
Result of an attempt to set up a GHC session for a Cradle
.
This is the go-to error handling mechanism. When possible, this
should be preferred over throwing exceptions.
CradleSuccess r | The cradle succeeded and returned these options. |
CradleFail CradleError | We tried to load the cradle and it failed. |
CradleNone | No attempt was made to load the cradle. |
Instances
data CradleError Source #
CradleError | |
|
Instances
Exception CradleError Source # | |
Defined in HIE.Bios.Types | |
Show CradleError Source # | |
Defined in HIE.Bios.Types showsPrec :: Int -> CradleError -> ShowS # show :: CradleError -> String # showList :: [CradleError] -> ShowS # | |
Eq CradleError Source # | |
Defined in HIE.Bios.Types (==) :: CradleError -> CradleError -> Bool # (/=) :: CradleError -> CradleError -> Bool # |
findCradle :: FilePath -> IO (Maybe FilePath) Source #
Given root/foo/bar.hs
, return root/hie.yaml
, or wherever the yaml file was found.
Note, findCradle
used to **not** work for directories and required a Haskell file.
This has been fixed since 0.14.0
.
However, loadCradle
and loadImplicitCradle
still require a Haskell
source file and won't work properly with a directory parameter.
loadCradle :: LogAction IO (WithSeverity Log) -> FilePath -> IO (Cradle Void) Source #
Given root/hie.yaml load the Cradle.
loadImplicitCradle :: Show a => LogAction IO (WithSeverity Log) -> FilePath -> IO (Cradle a) Source #
Given root/foo/bar.hs, load an implicit cradle
defaultCradle :: LogAction IO (WithSeverity Log) -> FilePath -> Cradle a Source #
Default cradle has no special options, not very useful for loading modules.
Compiler Options
data ComponentOptions Source #
Option information for GHC
ComponentOptions | |
|
Instances
Show ComponentOptions Source # | |
Defined in HIE.Bios.Types showsPrec :: Int -> ComponentOptions -> ShowS # show :: ComponentOptions -> String # showList :: [ComponentOptions] -> ShowS # | |
Eq ComponentOptions Source # | |
Defined in HIE.Bios.Types (==) :: ComponentOptions -> ComponentOptions -> Bool # (/=) :: ComponentOptions -> ComponentOptions -> Bool # | |
Ord ComponentOptions Source # | |
Defined in HIE.Bios.Types compare :: ComponentOptions -> ComponentOptions -> Ordering # (<) :: ComponentOptions -> ComponentOptions -> Bool # (<=) :: ComponentOptions -> ComponentOptions -> Bool # (>) :: ComponentOptions -> ComponentOptions -> Bool # (>=) :: ComponentOptions -> ComponentOptions -> Bool # max :: ComponentOptions -> ComponentOptions -> ComponentOptions # min :: ComponentOptions -> ComponentOptions -> ComponentOptions # |
:: FilePath | The file we are loading it because of |
-> [FilePath] | previous files we might want to include in the build |
-> Cradle a | |
-> IO (CradleLoadResult ComponentOptions) |
Initialize the DynFlags
relating to the compilation of a single
file or GHC session according to the provided Cradle
.
Initialising a GHC session from a Cradle
initSession :: GhcMonad m => ComponentOptions -> m [Target] Source #
Start a GHC session and set some sensible options for tooling to use. Creates a folder in the cache directory to cache interface files to make reloading faster.
Loading targets into a GHC session
:: 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.