Skip to content

Feature request: Support for formatting generated .cabal files using Gild or cabal-fmt #617

Open

Description

@webdevred

Hi,

Thanks for your great work on hpack! I’ve noticed that when hpack generates .cabal files, the output tends to lack consistent formatting. This can make diffs less easy to understand.

I would be happy if you considered adding support for formatting the generated .cabal files using established formatting tools such as Gild or cabal-fmt. These tools produce clean, idiomatic, and consistent Cabal files that are much easier to read.

Would you be open to adding this feature or providing an option to produce formatted .cabal files?

Thanks for considering this, and for all the effort you put into HPACK!

Activity

  1. sol commented on Oct 29, 2025

    @sol
    Owner
    1. I haven't used cabal-fmt myself, but from what I read in @tfausak's blog post, it is not diff friendly. Adding support for this specifically is not within the scope of hpack.
    2. Making sure that hpack plays nice with Glide could be viable, though.

    hpack extracts formatting hints from any existing .cabal file and tries to minimize diffs when producing output.

    In a perfect world

    hpack && glide && hpack
    

    would produce the same result as

    hpack && glide
    

    What this essentially means is that you would still need to run glide once, but after that hpack will preserve the formatting.

    Extracting formatting hints is based on heuristics and likely does not yet cover all scenarios.

    We can extend those heuristics so that hpack plays nice with Glide.

    Please feel free to open specific issues where hpack does not preserve the format of an existing .cabal file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions