[MLton] an analysis to flatten refs into tuples
Tue, 18 May 2004 09:36:54 -0700
> Do you mean doing something like:
> datatype t = A of int | B of int
> L0: ...
> case x of A => LA | B => LB
> LA(xa: ConApp A): ... a: int = ConSelect (xa, 0) ...
> LB(xb: ConApp B): ... b: int = ConSelect (xb, 0) ...
> Type checking the above certainly seems pretty straightforward.
> But, what is the type of z in the following?
> z = ConApp (A, #)
> Would we require another coercion statement to lift z (as a ConApp A) to a
> Datatype t?
That is the question. We can either make the coercion implicit or
explicit. If we make it implicit, we need a little bit of subtyping
in the IL. If we make it explicit, passes have to be more careful to
distinguish between the two different kinds of values. In particular,
when I tried this once before, I ran into shrinker problems. I don't
think it was anything deep, just that the code wasn't geared to keep
track of the distinction between a ConApp value of type ConApp A and
that same value, but of type t.
I also played with the subtyping when I tried this (years ago), but
wasn't comfortable at that time with such a big change to the type
system. Now that I have added subtyping (of an even more complicated
form) to the Rssa IL, I am confident I can do the same to Ssa. So,
I'm leaning towards that route.
> BTW, whatever is done to the IL, then the knownCase pass will take a
> real beating.
Yeah, I think this change is big enough that it's worth introducing
two Ssa ILs that will exist simultaneously for a while, and pushing
the new IL one pass at a time from the backend to the closure
converter. I'll let you know when I reach the knownCase pass so you
can have at it :-).