-
Notifications
You must be signed in to change notification settings - Fork 291
Closed
Description
Right now, constructors of a data type are printed out in hash order. The algorithm is basically:
- Hash all the constructor types
- Sort the list of constructors by these hashes
It's a stable sort, so constructors with the same type will remain in the same relative order.
My proposal which would be a simple pretty-printer change is something like:
- Group adjacent constructors that have the same type
- Sort groups of constructors alphabetically by the first element of each group
- Flatten the sorted list of groups
This will have the same hash as the existing constructor ordering, since we're only changing the order of things that have different hashes (and will be reordered by the canonical sort).
It would also be nice to do the fancier thing and record order in the database, but this is a very small, local change within the pretty-printer.