Spec for `package.yml` files + LSP Support
Good day,
I mainly use Stack to manage my projects. Therefore, I spend a lot of time editing package.yml files. For some reason the Yaml LSP always picks up these files as PNPM configuration files (probably because they share the same name).
I looked for a spec for the package.yml file format, to, surprisingly, no avail.
The only official specification I could find seems to be HPack’s Readme ( GitHub - sol/hpack: hpack: A modern format for Haskell packages · GitHub ).
Unless I missed something, I think it’s a bit of a shame that there’s not much more support for this config file, especially since Stack is what newcomers are more likely to use (vs. cabal) when setting up projects.
So I asked our “best” friend ChatGPT to derive a Yaml spec for it, using HPack’s Readme as a reference.
For archival purposes, I saved it as a Gist so that other people can use it: Schema for Hpack's package.yml · GitHub
For those interested, you simply have to add this line at the top of the package.yml file for the LSP to pick up the spec:
# yaml-language-server: $schema=<url-to-the-raw-gist>
This is by no means complete nor 100% correct, but it seems to work OK for simple configs, and it’s nice to have auto-completion (at least for field names).
The goal of the post is not to show off with an AI-generated shaky Yaml spec. It’s also to raise the question of the DX with this particular config file. I think it is worth looking into. As I said earlier, newcomers are more likely (I think) to use Stack than Cabal. And I believe LSP support/a proper spec would greatly help the DX.
Discussion in the ATmosphere