- 
                Notifications
    You must be signed in to change notification settings 
- Fork 723
Description
Describe the feature request
People often ask for a programmatic way to manipulate parts of the cabal file, especially w.r.t dependencies. A recent tool, cabal-add, delivers on the particular task. Should it be integrated into cabal proper?
Additional context
cabal-add (a tool adding entries in build-depends without ruining formatting in a cabal file) is being integrated into HLS: Bodigrim/cabal-add#7 This confirms my feeling that there's a user base for this feature, however partial this feature is.
I tried to read the implementation (it's reasonably small and clean). It juggles between [Field Position] and GenericPackageDescription like no tomorrow, starting from:
https://github.com/Bodigrim/cabal-add/blob/267eb6802477076b64568bff774aa7833bcbfa7b/src/Distribution/Client/Add.hs#L202-L210
... as is expected in the absence of a holistic solution for exact parsing (cf. #7544).
The core of it is three "algorithms" to solve the task (add a dependency) that spread across the spectrum: accuracy --- robustness (e.g. the first algorithm preserves formatting the best but is more fragile than the others)
- https://github.com/Bodigrim/cabal-add/blob/267eb6802477076b64568bff774aa7833bcbfa7b/src/Distribution/Client/Add.hs#L403-L407
- https://github.com/Bodigrim/cabal-add/blob/267eb6802477076b64568bff774aa7833bcbfa7b/src/Distribution/Client/Add.hs#L450-L453
- https://github.com/Bodigrim/cabal-add/blob/267eb6802477076b64568bff774aa7833bcbfa7b/src/Distribution/Client/Add.hs#L472-L475
Given that all of them are Maybe, I assume, the tool doesn't guarantee success...
Maybe we should wait and see how the HLS feature fares and what its users think?