cabal-add-0.2: Extend Cabal build-depends from the command line
Copyright(c) 2023 Bodigrim
LicenseBSD-3-Clause
Safe HaskellNone
LanguageGHC2021

Distribution.Client.Add

Description

Building blocks of cabal-add executable.

Synopsis

Documentation

parseCabalFile Source #

Arguments

:: MonadError String m 
=> FilePath

File name, just for error reporting.

-> ByteString

Contents of the Cabal file.

-> m ([Field Position], GenericPackageDescription)

Parsed data, suitable for resolveComponent.

Parse Cabal file into two representations.

resolveComponent Source #

Arguments

:: MonadError String m 
=> FilePath

File name, just for error reporting.

-> ([Field a], GenericPackageDescription)

Parsed Cabal file, as returned by parseCabalFile.

-> Maybe String

Component name (or default component if Nothing), roughly adhering to the syntax of component targets.

-> m (Either CommonStanza ComponentName)

Resolved component.

Resolve a raw component name.

newtype CommonStanza Source #

Just a newtype wrapper, since Cabal-syntax does not provide any.

Constructors

CommonStanza 

validateDependency Source #

Arguments

:: MonadError String m 
=> CabalSpecVersion

Cabal format version to adhere to.

-> String

Raw dependency to add.

-> m ByteString

Validated dependency as ByteString (or an error).

Validate dependency syntax, checking whether Cabal would be able to parse it.

data AddConfig Source #

An input for executeAddConfig.

Constructors

AddConfig 

Fields

Instances

Instances details
Show AddConfig Source # 
Instance details

Defined in Distribution.Client.Add

Eq AddConfig Source # 
Instance details

Defined in Distribution.Client.Add

executeAddConfig Source #

Arguments

:: (Either CommonStanza ComponentName -> ByteString -> Bool)

How to validate results? See validateChanges.

-> AddConfig

Input arguments.

-> Maybe ByteString

Updated contents, if validated successfully.

The main workhorse, adding fields to a specified component in the Cabal file.

validateChanges Source #

Arguments

:: GenericPackageDescription

Original package description.

-> Either CommonStanza ComponentName

Which component was supposed to be updated? Usually constructed by resolveComponent.

-> ByteString

Updated Cabal file.

-> Bool

Was the update successful?

Validate that updates did not cause unexpected effects on other sections of the Cabal file.

data TargetField Source #

A field in a cabal file, new content can be added to

Constructors

BuildDepends

Corresponds to build-depends in the cabal file

ExposedModules

Corresponds to exposed-modules in the cabal file

OtherModules

Corresponds to other-modules in the cabal file