4 <:Defunctorize:> is a translation pass from the <:CoreML:>
5 <:IntermediateLanguage:> to the <:XML:> <:IntermediateLanguage:>.
9 This pass converts a <:CoreML:> program to an <:XML:> program by
14 * polymorphic `val` dec expansion
15 * `datatype` lifting (to the top-level)
19 * <!ViewGitFile(mlton,master,mlton/defunctorize/defunctorize.sig)>
20 * <!ViewGitFile(mlton,master,mlton/defunctorize/defunctorize.fun)>
22 == Details and Notes ==
24 This pass is grossly misnamed and does not perform defunctorization.
26 === Datatype Lifting ===
28 This pass moves all `datatype` declarations to the top level.
30 <:StandardML:Standard ML> `datatype` declarations can contain type
31 variables that are not bound in the declaration itself. For example,
32 the following program is valid.
37 datatype 'b t = T of 'a * 'b
38 val y: int t = T (x, 1)
44 Unfortunately, the `datatype` declaration can not be immediately moved
45 to the top level, because that would leave `'a` free.
48 datatype 'b t = T of 'a * 'b
51 val y: int t = T (x, 1)
57 In order to safely move `datatype`s, this pass must close them, as
58 well as add any free type variables as extra arguments to the type
59 constructor. For example, the above program would be translated to
63 datatype ('a, 'b) t = T of 'a * 'b
66 val y: ('a * int) t = T (x, 1)
72 == Historical Notes ==
74 The <:Defunctorize:> pass originally eliminated
75 <:StandardML:Standard ML> functors by duplicating their body at each
76 application. These duties have been adopted by the <:Elaborate:>