Refactor the simplifier's treatment of case expressions
(NB: this patch could conceivably require some bits of the
following SpecConstr patch to compile cleanly. It's conceptually
independent, but I'm not 100% certain that I've included all
the necessary bits here.)
This patch cleans up the simplifier's handling of various
otimisations for case expressions, notably
- case elimination (discarding the case altogether)
- merging identical alternatives
- discarding impossible alternative
- merging nested cases
Previously this was partly handled before, and partly after,
simplifying the case alternatives. The trouble with that is
that the dead-ness information on the case binders gets munged
during simplification, and that turned out to mean that
case elmination essentially never happened -- stupid.
Now I've moved it all to before simplifying the alterntives.
In fact this reduces the amount of code, I think, and it's
certainly tidier. I don't think there is any loss.