
Claus Reinke wrote:
Strange. I don't think it is my idea (older implementations used to work that way, and iirc, it also matches what Prolog systems used to do), and I didn't think it was anything but straightforward to avoid case transformations unless there is a clear benefit, so I doubt there is a useful paper in there (also, I can't afford to plan that far ahead atm). What is the benefit of changing the ordering (not just joining paths to avoid redundant tests, but actually modifying the order of tests, to sort by their order in the data type declaration)? Is there any documentation of these case transformations that I could look up?
It's not that GHC deliberately re-orders case alternatives, it's that it doesn't deliberately not do it. That's quite an important difference. To check whether case alternatives ever get reordered, we'd have to look at the whole compiler. It's a new constraint on which transformations are valid, and global constraints should not be added lightly. I some kind of annotation is a much more promising avenue to explore. Cheers, Simon