ghc-mod-4.0.2: Happy Haskell Programming

Safe HaskellNone




Low level access to the ghc-mod library.



type LogReader = IO [String]Source

A means to read the log.

type GHCOption = StringSource

A single GHC command line option.

type Package = (PackageBaseName, Maybe String)Source

A package name and its ID.

type IncludeDir = FilePathSource

An include directory for modules.

data CompilerOptions Source

Option information for GHC




ghcOptions :: [GHCOption]

Command line options

includeDirs :: [IncludeDir]

Include directories for modules

depPackages :: [Package]

Dependent package names


userPackageDbOptsForGhc :: Maybe FilePath -> [String]Source

Creating user package db options for GHC.

>>> userPackageDbOptsForGhc (Just "/foo/bar/i386-osx-ghc-7.6.3-packages.conf.d")
>>> userPackageDbOptsForGhc (Just "/foo/bar/i386-osx-ghc-7.4.1-packages.conf.d")

userPackageDbOptsForGhcPkg :: Maybe FilePath -> [String]Source

Creating user package db options for ghc-pkg.

>>> userPackageDbOptsForGhcPkg (Just "/foo/bar/i386-osx-ghc-7.6.3-packages.conf.d")
>>> userPackageDbOptsForGhcPkg (Just "/foo/bar/i386-osx-ghc-7.4.1-packages.conf.d")

Cabal API

parseCabalFile :: FilePath -> IO PackageDescriptionSource

Parsing a cabal file and returns PackageDescription. IOException is thrown if parsing fails.

getCompilerOptions :: [GHCOption] -> Cradle -> PackageDescription -> IO CompilerOptionsSource

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 FilePaths for libraries, executables, tests and benchmarks.


getSystemLibDir :: IO (Maybe FilePath)Source

Obtaining the directory for system libraries.

getDynamicFlags :: IO DynFlagsSource

Return the DynFlags currently in use in the GHC session.

Initializing DynFlags

initializeFlags :: GhcMonad m => Options -> m ()Source

Initialize the DynFlags relating to the compilation of a single file or GHC session.

initializeFlagsWithCradle :: GhcMonad m => Options -> Cradle -> [GHCOption] -> Bool -> m (LogReader, Maybe PackageDescription)Source

Initialize the DynFlags relating to the compilation of a single file or GHC session according to the Cradle and Options provided.

Ghc Monad

setTargetFiles :: GhcMonad m => [FilePath] -> m ()Source

Set the files that GHC will load / compile.

addTargetFiles :: GhcMonad m => [FilePath] -> m ()Source

Adding the files to the targets.

browseAll :: DynFlags -> Ghc [(String, String)]Source

Browsing all functions in all system/user modules.

Ghc Choice

(||>) :: Ghc a -> Ghc a -> Ghc aSource

Try the left Ghc action. If IOException occurs, try the right Ghc action.

goNext :: Ghc aSource

Go to the next Ghc monad by throwing AltGhcgoNext.

runAnyOne :: [Ghc a] -> Ghc aSource

Run any one Ghc monad.

GhcMonad Choice

(|||>) :: GhcMonad m => m a -> m a -> m aSource

Try the left GhcMonad action. If IOException occurs, try the right GhcMonad action.