dynamic-cabal-0.3: dynamic-cabal

Safe HaskellNone

Distribution.Client.Dynamic.PackageDescription

Contents

Description

This module contains queries that operate on a PackageDescription. It provides a function to extract all targets along with their dependencies.

Synopsis

Data types for targets

data Target Source

A target is a single Library, an Executable, a TestSuite or a Benchmark.

Constructors

Target 

Fields

info :: TargetInfo

The specific info of the target

dependencies :: [(String, Maybe Version)]

All dependencies of the target, with their versions. If the version is not resolved yet, it'll be Nothing. That only happens when the target is not enabled, though.

sourceDirs :: [FilePath]

Directories where to look for source files.

includeDirs :: [FilePath]

Directories where to look for header files.

ghcOptions :: [String]

Additional options to pass to GHC when compiling source files.

cppOptions :: [String]

Additional options to pass to CPP preprocessor when compiling source files.

extensions :: [String]

The extensions to enable/disable. The elements are like GHC's -X flags, a disabled extension is represented as the extension name prefixed by No. Example value: extensions = [ScopedTypeVariables, NoMultiParamTypeClasses]

buildable :: Bool

The buildable field in the package description.

otherModules :: [String]

other modules included in the target

enabled :: Bool

Whether this target was enabled or not. This only matters for Benchmarks or Tests, Executables and Libraries are always enabled.

data TargetInfo Source

The specific information on a target, depending on the target type. Libraries don't have a name, they are always named after the package, but other types do

Constructors

Library [String]

contains the names of exposed modules

Executable String FilePath

contains the name of the executable and the path to the Main module

TestSuite String (Maybe FilePath)

contains the name of the test suite and the path to the Main module, for stdio tests

BenchSuite String (Maybe FilePath)

contains the name of the benchmark and the path to the Main module, for stdio benchmarks

data PackageDescription Source

A package description type. This type has no constructors, and is only used for type-safety purposes.

Queries

targets :: Query PackageDescription [Target]Source

Query the available targets. This will return all targets, even disabled ones. If a package is disabled or not buildable, it's possible that not all dependencies have versions, some can be Nothing.

targetName :: Target -> StringSource

return the target name, or the empty string for the library target

isLibrary :: Target -> BoolSource

is the target the library?

isExecutable :: Target -> BoolSource

is the target an executable?

isTest :: Target -> BoolSource

is the target a test suite?

isBench :: Target -> BoolSource

is the target a benchmark?

Lenses and traversals for target related data types

_name :: Applicative f => (String -> f String) -> TargetInfo -> f TargetInfoSource

Traverse the name of a target, if available (libraries don't have names).

_mainModule :: Applicative f => (FilePath -> f FilePath) -> TargetInfo -> f TargetInfoSource

Traverse the path of the main module, if available.

_ghcOptions :: Functor f => ([String] -> f [String]) -> Target -> f TargetSource

_cppOptions :: Functor f => ([String] -> f [String]) -> Target -> f TargetSource

_extensions :: Functor f => ([String] -> f [String]) -> Target -> f TargetSource

_enabled :: Functor f => (Bool -> f Bool) -> Target -> f TargetSource