cabal-helper-0.8.0.1: Simple interface to some of Cabal's configuration state, mainly used by ghc-mod

LicenseAGPL-3
Maintainerdxld@darkboxed.org
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Distribution.Helper

Contents

Description

 

Synopsis

Running Queries

data Query m a Source #

A lazy, cached, query against a package's Cabal configuration. Use runQuery to execute it.

Instances

MonadTrans Query Source # 

Methods

lift :: Monad m => m a -> Query m a #

Monad m => Monad (Query m) Source # 

Methods

(>>=) :: Query m a -> (a -> Query m b) -> Query m b #

(>>) :: Query m a -> Query m b -> Query m b #

return :: a -> Query m a #

fail :: String -> Query m a #

Functor m => Functor (Query m) Source # 

Methods

fmap :: (a -> b) -> Query m a -> Query m b #

(<$) :: a -> Query m b -> Query m a #

Monad m => Applicative (Query m) Source # 

Methods

pure :: a -> Query m a #

(<*>) :: Query m (a -> b) -> Query m a -> Query m b #

liftA2 :: (a -> b -> c) -> Query m a -> Query m b -> Query m c #

(*>) :: Query m a -> Query m b -> Query m b #

(<*) :: Query m a -> Query m b -> Query m a #

MonadIO m => MonadIO (Query m) Source # 

Methods

liftIO :: IO a -> Query m a #

runQuery :: Monad m => QueryEnv -> Query m a -> m a Source #

runQuery env query. Run a Query under a given QueryEnv.

Queries against Cabal's on disk state

Package queries

packageId :: MonadIO m => Query m (String, Version) Source #

Package identifier, i.e. package name and version

packageDbStack :: MonadIO m => Query m [ChPkgDb] Source #

List of package databases to use.

packageFlags :: MonadIO m => Query m [(String, Bool)] Source #

Flag definitions from cabal file

compilerVersion :: MonadIO m => Query m (String, Version) Source #

The version of GHC the project is configured to use

ghcMergedPkgOptions :: MonadIO m => Query m [String] Source #

Like ghcPkgOptions but for the whole package not just one component

cabal-install queries

configFlags :: MonadIO m => Query m [(String, Bool)] Source #

Flag assignments from setup-config

nonDefaultConfigFlags :: MonadIO m => Query m [(String, Bool)] Source #

Flag assignments from setup-config which differ from the default setting. This can also include flags which cabal decided to modify, i.e. don't rely on these being the flags set by the user directly.

Component queries

data ComponentQuery m a Source #

A Query to run on all components of a package. Use components to get a regular Query.

Instances

Functor m => Functor (ComponentQuery m) Source # 

Methods

fmap :: (a -> b) -> ComponentQuery m a -> ComponentQuery m b #

(<$) :: a -> ComponentQuery m b -> ComponentQuery m a #

(Functor m, Monad m) => Apply (ComponentQuery m) Source # 

Methods

(<.>) :: ComponentQuery m (a -> b) -> ComponentQuery m a -> ComponentQuery m b #

(.>) :: ComponentQuery m a -> ComponentQuery m b -> ComponentQuery m b #

(<.) :: ComponentQuery m a -> ComponentQuery m b -> ComponentQuery m a #

liftF2 :: (a -> b -> c) -> ComponentQuery m a -> ComponentQuery m b -> ComponentQuery m c #

components :: Monad m => ComponentQuery m (ChComponentName -> b) -> Query m [b] Source #

Run a ComponentQuery on all components of the package.

ghcSrcOptions :: MonadIO m => ComponentQuery m [String] Source #

Only search path related GHC options.

ghcPkgOptions :: MonadIO m => ComponentQuery m [String] Source #

Only package related GHC options, sufficient for things don't need to access any home modules.

ghcLangOptions :: MonadIO m => ComponentQuery m [String] Source #

Only language related options, i.e. -XSomeExtension

ghcOptions :: MonadIO m => ComponentQuery m [String] Source #

All options Cabal would pass to GHC.

sourceDirs :: MonadIO m => ComponentQuery m [FilePath] Source #

A component's source-dirs field, beware since if this is empty implicit behaviour in GHC kicks in.

entrypoints :: MonadIO m => ComponentQuery m ChEntrypoint Source #

Modules or files Cabal would have the compiler build directly. Can be used to compute the home module closure for a component.

needsBuildOutput :: MonadIO m => ComponentQuery m NeedsBuildOutput Source #

The component has a non-default module renaming, so needs build output ().

Query environment

data QueryEnv Source #

Environment for running a Query. The real constructor is not exposed, the field accessors are however. See below. Use the mkQueryEnv smart constructor to construct one.

mkQueryEnv Source #

Arguments

:: FilePath

Path to the project directory, i.e. the directory containing a project.cabal file

-> FilePath

Path to the dist/ directory, called builddir in Cabal terminology.

-> QueryEnv 

mkQueryEnv projdir distdir. Smart constructor for QueryEnv. Sets fields qeProjectDir and qeDistDir to projdir and distdir respectively and provides sensible defaults for the other fields.

qeReadProcess :: QueryEnv -> FilePath -> [String] -> String -> IO String Source #

Field accessor for QueryEnv. Defines how to start the cabal-helper process. Useful if you need to capture stderr output from the helper.

qePrograms :: QueryEnv -> Programs Source #

Field accessor for QueryEnv.

qeProjectDir :: QueryEnv -> FilePath Source #

Field accessor for QueryEnv. Defines path to the project directory, i.e. a directory containing a project.cabal file

qeDistDir :: QueryEnv -> FilePath Source #

Field accessor for QueryEnv. Defines path to the dist/ directory, builddir in Cabal terminology.

qeCabalPkgDb :: QueryEnv -> Maybe FilePath Source #

Field accessor for QueryEnv. Defines where to look for the Cabal library when linking the helper.

qeCabalVer :: QueryEnv -> Maybe Version Source #

Field accessor for QueryEnv. If dist/setup-config wasn't written by this version of Cabal an error is thrown when running the query.

data Programs Source #

Paths or names of various programs we need.

Constructors

Programs 

Fields

defaultPrograms :: Programs Source #

Default all programs to their unqualified names, i.e. they will be searched for on PATH.

Result types

data ChComponentName Source #

Instances

Eq ChComponentName Source # 
Ord ChComponentName Source # 
Read ChComponentName Source # 
Show ChComponentName Source # 
Generic ChComponentName Source # 
type Rep ChComponentName Source # 

data ChPkgDb Source #

Instances

Eq ChPkgDb Source # 

Methods

(==) :: ChPkgDb -> ChPkgDb -> Bool #

(/=) :: ChPkgDb -> ChPkgDb -> Bool #

Ord ChPkgDb Source # 
Read ChPkgDb Source # 
Show ChPkgDb Source # 
Generic ChPkgDb Source # 

Associated Types

type Rep ChPkgDb :: * -> * #

Methods

from :: ChPkgDb -> Rep ChPkgDb x #

to :: Rep ChPkgDb x -> ChPkgDb #

type Rep ChPkgDb Source # 
type Rep ChPkgDb = D1 * (MetaData "ChPkgDb" "CabalHelper.Shared.InterfaceTypes" "cabal-helper-0.8.0.1-IabXVCu5cDn4LK07E5Sdgi" False) ((:+:) * (C1 * (MetaCons "ChPkgGlobal" PrefixI False) (U1 *)) ((:+:) * (C1 * (MetaCons "ChPkgUser" PrefixI False) (U1 *)) (C1 * (MetaCons "ChPkgSpecific" PrefixI False) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * FilePath)))))

data ChEntrypoint Source #

Constructors

ChSetupEntrypoint

Almost like ChExeEntrypoint but main-is could either be "Setup.hs" or "Setup.lhs". Since we don't know where the source directory is you have to find these files.

ChLibEntrypoint 
ChExeEntrypoint 

Instances

Eq ChEntrypoint Source # 
Ord ChEntrypoint Source # 
Read ChEntrypoint Source # 
Show ChEntrypoint Source # 
Generic ChEntrypoint Source # 

Associated Types

type Rep ChEntrypoint :: * -> * #

type Rep ChEntrypoint Source # 
type Rep ChEntrypoint = D1 * (MetaData "ChEntrypoint" "CabalHelper.Shared.InterfaceTypes" "cabal-helper-0.8.0.1-IabXVCu5cDn4LK07E5Sdgi" False) ((:+:) * (C1 * (MetaCons "ChSetupEntrypoint" PrefixI False) (U1 *)) ((:+:) * (C1 * (MetaCons "ChLibEntrypoint" PrefixI True) ((:*:) * (S1 * (MetaSel (Just Symbol "chExposedModules") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * [ChModuleName])) ((:*:) * (S1 * (MetaSel (Just Symbol "chOtherModules") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * [ChModuleName])) (S1 * (MetaSel (Just Symbol "chSignatures") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * [ChModuleName]))))) (C1 * (MetaCons "ChExeEntrypoint" PrefixI True) ((:*:) * (S1 * (MetaSel (Just Symbol "chMainIs") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * FilePath)) (S1 * (MetaSel (Just Symbol "chOtherModules") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * [ChModuleName]))))))

data NeedsBuildOutput Source #

General information

Stuff that cabal-install really should export

getSandboxPkgDb Source #

Arguments

:: (FilePath -> [String] -> String -> IO String) 
-> FilePath

Cabal build platform, i.e. buildPlatform

-> Version

GHC version (cProjectVersion is your friend)

-> IO (Maybe FilePath) 

Get the path to the sandbox package-db in a project

Managing dist/

prepare :: MonadIO m => QueryEnv -> m () Source #

Make sure the appropriate helper executable for the given project is installed and ready to run queries.

reconfigure Source #

Arguments

:: MonadIO m 
=> (FilePath -> [String] -> String -> IO String) 
-> Programs

Program paths

-> [String]

Command line arguments to be passed to cabal

-> m () 

Run cabal configure

writeAutogenFiles :: MonadIO m => QueryEnv -> m () Source #

Create cabal_macros.h and Paths_<pkg> possibly other generated files in the usual place.

$libexec related error handling

data LibexecNotFoundError Source #

This exception is thrown by all runQuery functions if the internal wrapper executable cannot be found. You may catch this and present the user an appropriate error message however the default is to print libexecNotFoundError.

libexecNotFoundError Source #

Arguments

:: String

Name of the executable we were trying to find

-> FilePath

Path to $libexecdir

-> String

URL the user will be directed towards to report a bug.

-> String 

Reexports