License | GPL-3 |
---|---|
Maintainer | cabal-helper@dxld.at |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Distribution.Helper
Contents
Description
Synopsis
- data Query m a
- runQuery :: Monad m => QueryEnv -> Query m a -> m a
- packageId :: MonadIO m => Query m (String, Version)
- packageDbStack :: MonadIO m => Query m [ChPkgDb]
- packageFlags :: MonadIO m => Query m [(String, Bool)]
- compilerVersion :: MonadIO m => Query m (String, Version)
- ghcMergedPkgOptions :: MonadIO m => Query m [String]
- configFlags :: MonadIO m => Query m [(String, Bool)]
- nonDefaultConfigFlags :: MonadIO m => Query m [(String, Bool)]
- data ComponentQuery m a
- components :: Monad m => ComponentQuery m (ChComponentName -> b) -> Query m [b]
- ghcSrcOptions :: MonadIO m => ComponentQuery m [String]
- ghcPkgOptions :: MonadIO m => ComponentQuery m [String]
- ghcLangOptions :: MonadIO m => ComponentQuery m [String]
- ghcOptions :: MonadIO m => ComponentQuery m [String]
- sourceDirs :: MonadIO m => ComponentQuery m [FilePath]
- entrypoints :: MonadIO m => ComponentQuery m ChEntrypoint
- needsBuildOutput :: MonadIO m => ComponentQuery m NeedsBuildOutput
- data QueryEnv
- mkQueryEnv :: FilePath -> FilePath -> QueryEnv
- qeReadProcess :: QueryEnv -> FilePath -> [String] -> String -> IO String
- qePrograms :: QueryEnv -> Programs
- qeProjectDir :: QueryEnv -> FilePath
- qeDistDir :: QueryEnv -> FilePath
- qeCabalPkgDb :: QueryEnv -> Maybe FilePath
- qeCabalVer :: QueryEnv -> Maybe Version
- data Programs = Programs {
- cabalProgram :: FilePath
- ghcProgram :: FilePath
- ghcPkgProgram :: FilePath
- defaultPrograms :: Programs
- newtype ChModuleName = ChModuleName String
- data ChComponentName
- = ChSetupHsName
- | ChLibName
- | ChSubLibName String
- | ChFLibName String
- | ChExeName String
- | ChTestName String
- | ChBenchName String
- data ChPkgDb
- = ChPkgGlobal
- | ChPkgUser
- | ChPkgSpecific FilePath
- data ChEntrypoint
- = ChSetupEntrypoint
- | ChLibEntrypoint { }
- | ChExeEntrypoint {
- chMainIs :: FilePath
- chOtherModules :: [ChModuleName]
- data NeedsBuildOutput
- buildPlatform :: (FilePath -> [String] -> String -> IO String) -> IO String
- getSandboxPkgDb :: (FilePath -> [String] -> String -> IO String) -> String -> Version -> IO (Maybe FilePath)
- prepare :: MonadIO m => QueryEnv -> m ()
- reconfigure :: MonadIO m => (FilePath -> [String] -> String -> IO String) -> Programs -> [String] -> m ()
- writeAutogenFiles :: MonadIO m => QueryEnv -> m ()
- data LibexecNotFoundError = LibexecNotFoundError String FilePath
- libexecNotFoundError :: String -> FilePath -> String -> String
Running Queries
A lazy, cached, query against a package's Cabal configuration. Use
runQuery
to execute it.
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 # | |
Defined in Distribution.Helper 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 # | |
Defined in Distribution.Helper 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
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.
Arguments
:: FilePath | Path to the project directory, i.e. the directory containing a
|
-> FilePath | Path to the |
-> 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.
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.
Paths or names of various programs we need.
Constructors
Programs | |
Fields
|
Instances
Eq Programs Source # | |
Ord Programs Source # | |
Defined in Distribution.Helper | |
Read Programs Source # | |
Defined in Distribution.Helper | |
Show Programs Source # | |
Generic Programs Source # | |
type Rep Programs Source # | |
Defined in Distribution.Helper type Rep Programs = D1 (MetaData "Programs" "Distribution.Helper" "cabal-helper-0.8.2.0-6qqWhOruXPH9pSGwdgWHFa" False) (C1 (MetaCons "Programs" PrefixI True) (S1 (MetaSel (Just "cabalProgram") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 FilePath) :*: (S1 (MetaSel (Just "ghcProgram") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 FilePath) :*: S1 (MetaSel (Just "ghcPkgProgram") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 FilePath)))) |
defaultPrograms :: Programs Source #
Default all programs to their unqualified names, i.e. they will be searched
for on PATH
.
Result types
newtype ChModuleName Source #
Constructors
ChModuleName String |
Instances
data ChComponentName Source #
Constructors
ChSetupHsName | |
ChLibName | |
ChSubLibName String | |
ChFLibName String | |
ChExeName String | |
ChTestName String | |
ChBenchName String |
Instances
Eq ChComponentName Source # | |
Defined in CabalHelper.Shared.InterfaceTypes Methods (==) :: ChComponentName -> ChComponentName -> Bool (/=) :: ChComponentName -> ChComponentName -> Bool | |
Ord ChComponentName Source # | |
Defined in CabalHelper.Shared.InterfaceTypes Methods compare :: ChComponentName -> ChComponentName -> Ordering (<) :: ChComponentName -> ChComponentName -> Bool (<=) :: ChComponentName -> ChComponentName -> Bool (>) :: ChComponentName -> ChComponentName -> Bool (>=) :: ChComponentName -> ChComponentName -> Bool max :: ChComponentName -> ChComponentName -> ChComponentName min :: ChComponentName -> ChComponentName -> ChComponentName | |
Read ChComponentName Source # | |
Defined in CabalHelper.Shared.InterfaceTypes Methods readsPrec :: Int -> ReadS ChComponentName readList :: ReadS [ChComponentName] readPrec :: ReadPrec ChComponentName readListPrec :: ReadPrec [ChComponentName] | |
Show ChComponentName Source # | |
Defined in CabalHelper.Shared.InterfaceTypes Methods showsPrec :: Int -> ChComponentName -> ShowS show :: ChComponentName -> String showList :: [ChComponentName] -> ShowS | |
Generic ChComponentName Source # | |
Defined in CabalHelper.Shared.InterfaceTypes Associated Types type Rep ChComponentName :: Type -> Type Methods from :: ChComponentName -> Rep ChComponentName x to :: Rep ChComponentName x -> ChComponentName | |
type Rep ChComponentName Source # | |
Defined in CabalHelper.Shared.InterfaceTypes type Rep ChComponentName = D1 (MetaData "ChComponentName" "CabalHelper.Shared.InterfaceTypes" "cabal-helper-0.8.2.0-6qqWhOruXPH9pSGwdgWHFa" False) ((C1 (MetaCons "ChSetupHsName" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "ChLibName" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "ChSubLibName" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)))) :+: ((C1 (MetaCons "ChFLibName" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)) :+: C1 (MetaCons "ChExeName" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String))) :+: (C1 (MetaCons "ChTestName" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)) :+: C1 (MetaCons "ChBenchName" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String))))) |
Constructors
ChPkgGlobal | |
ChPkgUser | |
ChPkgSpecific FilePath |
Instances
Eq ChPkgDb Source # | |
Ord ChPkgDb Source # | |
Read ChPkgDb Source # | |
Defined in CabalHelper.Shared.InterfaceTypes | |
Show ChPkgDb Source # | |
Generic ChPkgDb Source # | |
type Rep ChPkgDb Source # | |
Defined in CabalHelper.Shared.InterfaceTypes type Rep ChPkgDb = D1 (MetaData "ChPkgDb" "CabalHelper.Shared.InterfaceTypes" "cabal-helper-0.8.2.0-6qqWhOruXPH9pSGwdgWHFa" False) (C1 (MetaCons "ChPkgGlobal" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "ChPkgUser" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "ChPkgSpecific" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 FilePath)))) |
data ChEntrypoint Source #
Constructors
ChSetupEntrypoint | Almost like |
ChLibEntrypoint | |
Fields
| |
ChExeEntrypoint | |
Fields
|
Instances
Eq ChEntrypoint Source # | |
Defined in CabalHelper.Shared.InterfaceTypes | |
Ord ChEntrypoint Source # | |
Defined in CabalHelper.Shared.InterfaceTypes Methods compare :: ChEntrypoint -> ChEntrypoint -> Ordering (<) :: ChEntrypoint -> ChEntrypoint -> Bool (<=) :: ChEntrypoint -> ChEntrypoint -> Bool (>) :: ChEntrypoint -> ChEntrypoint -> Bool (>=) :: ChEntrypoint -> ChEntrypoint -> Bool max :: ChEntrypoint -> ChEntrypoint -> ChEntrypoint min :: ChEntrypoint -> ChEntrypoint -> ChEntrypoint | |
Read ChEntrypoint Source # | |
Defined in CabalHelper.Shared.InterfaceTypes Methods readsPrec :: Int -> ReadS ChEntrypoint readList :: ReadS [ChEntrypoint] readPrec :: ReadPrec ChEntrypoint readListPrec :: ReadPrec [ChEntrypoint] | |
Show ChEntrypoint Source # | |
Defined in CabalHelper.Shared.InterfaceTypes Methods showsPrec :: Int -> ChEntrypoint -> ShowS show :: ChEntrypoint -> String showList :: [ChEntrypoint] -> ShowS | |
Generic ChEntrypoint Source # | |
Defined in CabalHelper.Shared.InterfaceTypes Associated Types type Rep ChEntrypoint :: Type -> Type | |
type Rep ChEntrypoint Source # | |
Defined in CabalHelper.Shared.InterfaceTypes type Rep ChEntrypoint = D1 (MetaData "ChEntrypoint" "CabalHelper.Shared.InterfaceTypes" "cabal-helper-0.8.2.0-6qqWhOruXPH9pSGwdgWHFa" False) (C1 (MetaCons "ChSetupEntrypoint" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "ChLibEntrypoint" PrefixI True) (S1 (MetaSel (Just "chExposedModules") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [ChModuleName]) :*: (S1 (MetaSel (Just "chOtherModules") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [ChModuleName]) :*: S1 (MetaSel (Just "chSignatures") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [ChModuleName]))) :+: C1 (MetaCons "ChExeEntrypoint" PrefixI True) (S1 (MetaSel (Just "chMainIs") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 FilePath) :*: S1 (MetaSel (Just "chOtherModules") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [ChModuleName])))) |
data NeedsBuildOutput Source #
Constructors
ProduceBuildOutput | |
NoBuildOutput |
Instances
General information
buildPlatform :: (FilePath -> [String] -> String -> IO String) -> IO String Source #
Stuff that cabal-install really should export
Arguments
:: (FilePath -> [String] -> String -> IO String) | |
-> String | Cabal build platform, i.e. |
-> Version | GHC version ( |
-> 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.
Arguments
:: MonadIO m | |
=> (FilePath -> [String] -> String -> IO String) | |
-> Programs | Program paths |
-> [String] | Command line arguments to be passed to |
-> 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
.
Constructors
LibexecNotFoundError String FilePath |
Instances
Show LibexecNotFoundError Source # | |
Defined in Distribution.Helper Methods showsPrec :: Int -> LibexecNotFoundError -> ShowS show :: LibexecNotFoundError -> String showList :: [LibexecNotFoundError] -> ShowS | |
Exception LibexecNotFoundError Source # | |
Defined in Distribution.Helper Methods toException :: LibexecNotFoundError -> SomeException fromException :: SomeException -> Maybe LibexecNotFoundError displayException :: LibexecNotFoundError -> String |
Arguments
:: String | Name of the executable we were trying to find |
-> FilePath | Path to |
-> String | URL the user will be directed towards to report a bug. |
-> String |