[MLton] Var.t -> Type.t ?

Lukasz S Ziarek lziarek@cs.purdue.edu
Fri, 16 Jan 2004 12:40:01 -0500 (EST)


Concerning the second part of your suggestion to get flatten.fun to
flatten all tupples (the changing of varTuple from NONE to SOME xs so that
flattens will
do it thing), the general methodology to setting the varTuple to some  is:

val tys = Type.detuple ty
val xs = Vector.map (tys, fn _ => Var.newNoname ())
val _ = varTuple x := SOME xs

The problem is that whenever I want to set varTuple to some, I do not have
the types available to do the above construction.

I can easily set varTuple to some in cases like:
 val fromFormal = fn (x, ty) => let val r = Rep.fromType ty
				     in
				       setVarInfo (x, {rep = r,
						       tuple = ref NONE})
				       ; r
				     end

But not so easily in cases as such:

 Property.getSetOnce
	 (Var.plist, Property.initFun
	             (fn _ => {rep = let val r = Rep.new ()
				     in if Rep.flattenALL then r
                                        else (Rep.tuplize r; r)
				     end,
			       tuple = ref NONE}))


Is there anyway to get a Type from a Var? Or better yet, a different way
to accomplish setting varTuple?  doitTransfer does not set varTuple for
any of its args, yet it calls flattens, so I will need to set varTuple
there as well correct (once again the problem of not have the type
readily available)? I believe I listed all the cases in which varTuple
needs to be set.

Luke