Open travisbrown opened 3 years ago
I think the reason is to allow implementations to use an unsorted collection (like a hashmap) to store the contents of a record
@Nadrieril That seems reasonable. Should we specify it in imports.md
, though, since it's as much a matter of "requiring" a sort as of "allowing" an unsorted representation? Unless the test comparisons are supposed to ignore field order? I don't think that's the case but don't remember for sure.
Hm, either would be a fine solution. I'd prefer mentioning that comparisons ignore order because it leaves more choice to implementors. The only place where we really require sorting is the CBOR encoding
Sorting the fields is a part of β-normalizing record types and values: https://github.com/dhall-lang/dhall-lang/blob/master/standard/beta-normalization.md#records
I don't think it should be a required part of import resolution – I think the field order in tests/import/success/unit/MixImportModesB.dhall
should simply be fixed.
Regarding specifying that the import tests may ignore the field order, I think that's a reasonable idea.
I would also be fine removing β-normalization from the import process (for imports not protected by a semantic integrity check). The mandatory normalization has actually ended up being counter-productive for large packages like dhall-kubernetes
which have very large normal forms.
I was just updating Dhall for Java after #1190, which turned up a bug in our test setup: we had been normalising after resolving imports in the import tests, so the fixes in #1190 for e.g.
AlternativeWithVariable
broke our tests.After fixing our test setup, there's one test that's newly failing, and I'm not sure whether it's a bug in our implementation or in the tests (or in the standard). It's
import/success/unit/MixImportModes
, where the input looks like this:And the expected result like this:
Our import tests no longer normalise after resolving, and our import resolution implementation doesn't sort the expression where imports are being resolved, so the test fails, since it maintains the original order.
Is import resolution supposed to sort record fields? Is there some other reason
MixImportModesB.dhall
is sorted? It's been a while since I've spent any time looking at the import resolution section of the standard so I might be missing something.