[MLton] modifying flatten.fun to always flatten

Lukasz S Ziarek lziarek@cs.purdue.edu
Sun, 18 Jan 2004 15:45:50 -0500 (EST)


I opted for the first suggestion that stephen posted (creating a new
property that associated types with variables). I though this would be the
better way to go, since I can simply do all preprocessing in one place for
the flattenALL case. This is the code (end of message) that I use to
accomplish the task.
During a fix point, in the second round compilation, the compiler reaches
 the knowcase part of simplify (about 4-5 steps after flatten is called
and localflatten3). I then recieve the following compiler message -

MLton raised in 430.56 + 0.00 (0% GC)
unhandled exception: Option

Could someone give a rough overview of
what knowcase does and any potential interactions with tupples.


val {get = varInfo: Var.t -> {rep: Rep.t,
				    tuple: Var.t vector option ref},
	   set = setVarInfo, ...} =
	 Property.getSetOnce
	 (Var.plist, Property.initFun
	             (fn x =>
		              if Rep.flattenALL andalso Type.isTuple(varTyp x)
                              then let val tys = Type.detuple(varTyp x)
                                       val xs = Vector.map (tys, fn _ => Var.newNoname())
                                   in  {rep = Rep.new(),
                                        tuple = ref (SOME xs)}
                                   end
                              else let val r = Rep.new()
                                   in  {rep = (Rep.tuplize r; r),
                                        tuple = ref NONE}
                                   end))