haskell / haskell/cabal

Adopt cabal-add?

Open
#10,272 8 comments 1 reaction 0 assignees View on GitHub
exact-print type: discussion
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

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](https://github.com/Bodigrim/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: https://github.com/Bodigrim/cabal-add/issues/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. https://github.com/haskell/cabal/issues/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?

Contributor guide

Open the contributing guide

Research direction

Start by reading cabal-add's Distribution/Client/Add.hs, especially the cited sections around lines 202-210, 403-407, 450-453, and 472-475. Review the linked HLS integration and the exact-parsing discussion in issue 7544, then determine whether the feature has a sufficiently defined scope and robustness expectations for cabal proper; done means an agreed integration direction or explicit decision not to adopt it.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.