Dhall-haskell: dhall format flag to sort fields(/etc)

Created on 18 Aug 2019  路  4Comments  路  Source: dhall-lang/dhall-haskell

It'd occasionally be handy to be able to run something like dhall format --sort, which would also sort expressions as well as canonicalising other formatting. This would be useful in preparing the expected output of tests compared textually (as, e.g., dhall-to-cabal uses).

formatting

Most helpful comment

I'll try: The various outputs of dhall are consistently pretty-printed - I remember this change being made deliberately. So, we could view dhall sort as something like the composition of a sort operation and then a format operation, neither of which change semantics. But pretty-printing without changing semantics is the core function of dhall format, so dhall format --sort makes more sense to me than a separate dhall sort (which would presumably grow all of the other features of dhall format as well).

With all that said, I don't actually care too much about which colour this bikeshed's painted.

All 4 comments

@sjakobi noted in https://github.com/dhall-lang/dhall-haskell/issues/1187#issuecomment-522693304 that we could separate out field sorting into a separate step and if we did that then the command-line API I'd suggest is a dhall sort subcommand (since we have sub-commands for type/resolve/normalize, so this would conceptually be another sub-command for the sorting phase).

That'd be fine too, but I think a format flag makes sense since (I assume) dhall sort would produce formatted output anyway (and doing otherwise - i.e., trying to preserve input formatting - is non-trivial); stage-separating type / resolve / normalize makes sense because the earlier stages don't come bundled with the later ones in the same way.

@quasicomputational: It's not clear to me what you meant by:

I think a format flag makes sense since (I assume) dhall sort would produce formatted output anyway

Could you expand on that?

I'll try: The various outputs of dhall are consistently pretty-printed - I remember this change being made deliberately. So, we could view dhall sort as something like the composition of a sort operation and then a format operation, neither of which change semantics. But pretty-printing without changing semantics is the core function of dhall format, so dhall format --sort makes more sense to me than a separate dhall sort (which would presumably grow all of the other features of dhall format as well).

With all that said, I don't actually care too much about which colour this bikeshed's painted.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thebritican picture thebritican  路  17Comments

quasicomputational picture quasicomputational  路  19Comments

AndrasKovacs picture AndrasKovacs  路  29Comments

Michael-Kateregga picture Michael-Kateregga  路  26Comments

FintanH picture FintanH  路  19Comments