Description
In the wake of the exact-printer initiative, I proposed another approach: why not say good bye to the .cabal file format and switch to something that is widely supported.
There is a few alternatives, the most important attribute would be that they are widely supported in industry.
- JSON
- YAML
- TOML
Note that all of these are (mostly) isomorphic to JSON (scalars, lists, dicts), which is important for easy translation between them (e.g. for config generation purposes).
What would this give the Haskell ecosystem?
- Editor support: every modern editor like
vscode
has a way of assigning JSON schema to a file, which gives completion and inline documentation for free everywhere - Also, syntax highlighting and auto formatting come for free
- Cabal doesn’t need to implement its own parser. If JSON is chosen, the parser is even context-free.
What would it give to users?
- Instant familiarity with the format: you don’t touch cabal files all too often as a user, so you don’t want to learn yet another syntax
- Templating cabal config with standard tooling (e.g.
jq
,yj
), which is important e.g. in a monorepo context - Inline documentation without setup
What are others doing?
Most modern package managers that don’t go the full turing-complete configuration route (e.g. Scala’s sbt, Erlang) usually converge their config on a widely supported syntax.
Examples:
- npm, yarn (
package.json
,package-lock.json
) - Stack (
stack.yaml
,stack.yaml.lock
) - hpack (
project.yaml
) - cargo (
Cargo.toml
) - Elm (
elm-package.json
) - Maven (
pom.xml
) - poetry (
pyproject.toml
,poetry.lock
)
Counterexamples:
- go (
go.mod
), though flat shasums and go packages have no configuration file - pip (
requirements.txt
), though see poetry above - sbt, hex: both use their turing complete parent languages
- leiningen (
project.clj
), clojure is a lisp, and sexps are already a data format
I don’t expect cabal would drop support for the cabal file format very soon, rather it would start out by generating a .cabal
file from the .json/.toml/.yaml
for consumption by older version of cabal. Then after a multi-year grace period, the new format would become the standard and projects could drop their autogenerated .cabal files.