Closed philderbeast closed 4 years ago
Hey! Thanks for opening this issue!
I think this can be provided as a third-party executable. Please feel free to do so.
Regarding adding this to hpack
itself: Unless somebody can make the case on how this benefits hpack
users at large, I'm not inclined to do so.
In the past I've used a separate YAML pretty printer for this and it's worked fine.
I look for fields like name
and version
at the head of a package.yaml
file or .cabal
files and expect to find exposed-modules
before other-modules
and library
before test-suite
. This is the order fields are listed in the top-level table and other tables in the hpack docs.
I have implemented a sorting of sorts for hpack field names following the hpack docs.
Can you please consider exposing a field name comparison function in hpack itself as a lesser suggestion?
@philderbeast for your specific used case, one thing I that could be worth trying is reading package.yaml
into a Value
and then compare it based on that.
I'm closing this issue, but please, if you need any changes to hpack
s API, please bring them up and I'm open to discuss (no promises).
@tfausak, what separate yaml pretty printer do you use? We use the imported anchor features pretty extensively in our package.yaml
files. This messes up every single yaml formatter I've tried.
Here's an example of an error with prettier
, but this is basically what I get with any of the other formatters:
$ prettier package.yaml
package.yaml
[error] package.yaml: SyntaxError: Aliased anchor not found: defaults (5:5)
[error] > 5 | <<: *defaults
[error] | ^^^^^^^^^
Please add a
format
command to hpack with an--inplace
option to overwrite thepackage.yaml
file.If a
format
command was added to hpack then use of this command could help to reduce the chance of git conflicts when rebasing/merging.Differences
I'm currently adding some real world golden tests for the executable
dhall-hpack-yaml
from packagehpack-dhall
, trying to generate output that matches hpack'spackage.yaml
and stack'spackage.yaml
. The kinds of differences I've seen between handwritten and generatedpackage.yaml
files are;dependencies:
category: Development maintainer: Simon Hengel sol@typeful.net extra-source-files: CHANGELOG.md github: sol/hpack
maintainer: Simon Hengel sol@typeful.net github: sol/hpack category: Development extra-source-files:
dependencies: hpack
dependencies:
executable: source-dirs: driver dependencies: hpack main: Main.hs tests: spec:
executable: main: Main.hs source-dirs: driver dependencies:
tests: spec:
name: stack version: ! '''1.10.0'''
name: stack version: '1.10.0'
name: hpack version: 0.31.1