haskell / haskell/cabal

`cabal format` inlines and removes `common` stanzas

Open
#5,734 12 comments 1 reaction 0 assignees View on GitHub
cabal-install: cmd/format Cabal: common stanza exact-print type: discussion
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

# Overview

When running `cabal format`, all `common` stanzas are inlined into the blocks they're referenced from.

## Example

**Before:**

```
cabal-version: 2.4
name: inittest
version: 0.1.0.0
build-type: Simple

common common-deps
default-language: Haskell2010
build-depends: base >=4.12 && <4.13

library
import: common-deps
exposed-modules:
MyLib
hs-source-dirs: src

executable inittest
import: common-deps
main-is: Main.hs
hs-source-dirs: app
build-depends:
inittest -any
```

**After:**

```
cabal-version: 2.4
name: inittest
version: 0.1.0.0
build-type: Simple

library
exposed-modules:
MyLib
hs-source-dirs: src
default-language: Haskell2010
build-depends:
base >=4.12 && <4.13

executable inittest
main-is: Main.hs
hs-source-dirs: app
default-language: Haskell2010
build-depends:
base >=4.12 && <4.13,
inittest -any
```

/cc @phadej @hvr

Contributor guide

Open the contributing guide

Research direction

Start by locating the `cabal format` implementation and its existing formatter tests, then reproduce the supplied before-and-after example. Done means formatting preserves the `common` stanza and its imports instead of inlining and removing them, with a regression test covering the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.