Safe Haskell | None |
---|---|
Language | Haskell2010 |
Low level access to the ghc-mod library.
- type GHCOption = String
- type Package = (PackageBaseName, PackageVersion, PackageId)
- type PackageBaseName = String
- type PackageVersion = String
- type PackageId = String
- type IncludeDir = FilePath
- data CompilerOptions = CompilerOptions {
- ghcOptions :: [GHCOption]
- includeDirs :: [IncludeDir]
- depPackages :: [Package]
- parseCabalFile :: (IOish m, MonadError GhcModError m) => Cradle -> FilePath -> m PackageDescription
- getCompilerOptions :: (IOish m, MonadError GhcModError m) => [GHCOption] -> Cradle -> PackageDescription -> m CompilerOptions
- cabalAllBuildInfo :: PackageDescription -> [BuildInfo]
- cabalDependPackages :: [BuildInfo] -> [PackageBaseName]
- cabalSourceDirs :: [BuildInfo] -> [IncludeDir]
- cabalAllTargets :: PackageDescription -> IO ([String], [String], [String], [String])
- ghcLibDir :: FilePath
- getDynamicFlags :: IO DynFlags
- setTargetFiles :: IOish m => [FilePath] -> GhcModT m ()
- withLogger :: IOish m => (DynFlags -> DynFlags) -> GhcModT m () -> GhcModT m (Either String String)
- setNoWarningFlags :: DynFlags -> DynFlags
- setAllWarningFlags :: DynFlags -> DynFlags
- data GhcModEnv = GhcModEnv {}
- newGhcModEnv :: Options -> FilePath -> IO GhcModEnv
- data GhcModState
- defaultState :: GhcModState
- data CompilerMode
- type GhcModLog = ()
- runGhcModT' :: IOish m => GhcModEnv -> GhcModState -> GhcModT m a -> m (Either GhcModError (a, GhcModState), GhcModLog)
- hoistGhcModT :: IOish m => (Either GhcModError a, GhcModLog) -> GhcModT m a
- options :: IOish m => GhcModT m Options
- cradle :: IOish m => GhcModT m Cradle
- getCompilerMode :: IOish m => GhcModT m CompilerMode
- setCompilerMode :: IOish m => CompilerMode -> GhcModT m ()
- withOptions :: IOish m => (Options -> Options) -> GhcModT m a -> GhcModT m a
- (||>) :: GhcMonad m => m a -> m a -> m a
- goNext :: GhcMonad m => m a
- runAnyOne :: GhcMonad m => [m a] -> m a
Types
type Package = (PackageBaseName, PackageVersion, PackageId) Source
A package's name, verson and id.
type PackageBaseName = String Source
A package name.
type PackageVersion = String Source
A package version.
type IncludeDir = FilePath Source
An include directory for modules.
data CompilerOptions Source
Option information for GHC
CompilerOptions | |
|
Cabal API
parseCabalFile :: (IOish m, MonadError GhcModError m) => Cradle -> FilePath -> m PackageDescription Source
Parse a cabal file and return a PackageDescription
.
getCompilerOptions :: (IOish m, MonadError GhcModError m) => [GHCOption] -> Cradle -> PackageDescription -> m CompilerOptions Source
Getting necessary CompilerOptions
from three information sources.
cabalAllBuildInfo :: PackageDescription -> [BuildInfo] Source
Extracting all BuildInfo
for libraries, executables, and tests.
cabalDependPackages :: [BuildInfo] -> [PackageBaseName] Source
Extracting package names of dependency.
cabalSourceDirs :: [BuildInfo] -> [IncludeDir] Source
Extracting include directories for modules.
cabalAllTargets :: PackageDescription -> IO ([String], [String], [String], [String]) Source
Extracting all Module
FilePath
s for libraries, executables,
tests and benchmarks.
GHC.Paths
IO
getDynamicFlags :: IO DynFlags Source
Return the DynFlags
currently in use in the GHC session.
Targets
setTargetFiles :: IOish m => [FilePath] -> GhcModT m () Source
Set the files as targets and load them.
Logging
withLogger :: IOish m => (DynFlags -> DynFlags) -> GhcModT m () -> GhcModT m (Either String String) Source
Set the session flag (e.g. "-Wall" or "-w:") then
executes a body. Logged messages are returned as String
.
Right is success and Left is failure.
setNoWarningFlags :: DynFlags -> DynFlags Source
Set DynFlags
equivalent to "-w:".
setAllWarningFlags :: DynFlags -> DynFlags Source
Set DynFlags
equivalent to "-Wall".
Environment, state and logging
Monad m => MonadReader GhcModEnv (GhcModT m) |
Monad utilities
runGhcModT' :: IOish m => GhcModEnv -> GhcModState -> GhcModT m a -> m (Either GhcModError (a, GhcModState), GhcModLog) Source
Run a computation inside GhcModT
providing the RWST environment and
initial state. This is a low level function, use it only if you know what to
do with GhcModEnv
and GhcModState
.
You should probably look at runGhcModT
instead.
hoistGhcModT :: IOish m => (Either GhcModError a, GhcModLog) -> GhcModT m a Source
hoistGhcModT result
. Embed a GhcModT computation's result into a GhcModT
computation. Note that if the computation that returned result
modified the
state part of GhcModT this cannot be restored.
Accessing GhcModEnv
and GhcModState
getCompilerMode :: IOish m => GhcModT m CompilerMode Source
setCompilerMode :: IOish m => CompilerMode -> GhcModT m () Source
GhcMonad
Choice
(||>) :: GhcMonad m => m a -> m a -> m a Source
Try the left Ghc
action. If IOException
occurs, try
the right Ghc
action.