brendanhay / amazonka

A comprehensive Amazon Web Services SDK for Haskell.
https://amazonka.brendanhay.nz
Other
599 stars 227 forks source link

Gen sorted interfaces #862

Closed endgame closed 1 year ago

endgame commented 1 year ago

Switch the generator from HashMap to Map, which means that all the toList calls come out in sorted order. This will keep the ordering of fields predictable and should give us better diffs in future generator runs.

While it might be nice to follow botocore's ordering for struct fields, I can't see a good way to do that: https://github.com/haskell/aeson/issues/984

A full regeneration is on the endgame:gen-sorted-interfaces-gen branch (#863). Please try it and let me know if you think this is better than the arbitrary "however HashMap.toList sorted them" that we used to have.

Closes #825 .

endgame commented 1 year ago

It seems unlikely that aeson will gain the ability to do sorted Objects any time soon, so I think that makes sorted fields a better way to go.

mbj commented 1 year ago

Please try it and let me know if you think this is better than the arbitrary "however HashMap.toList sorted them" that we used to have.

I did not try the branch. But determinism that does not depend on an implementation artifact (that in case of HashMap should actually not be that stable, to avoid collision / DOS attacs!) is better.

Given we cannot (easily) retain the source field order ATM, I think sorting by field name is the best compromise.