| 1 |
= XMLSimplifyTypes |
| 2 |
|
| 3 |
<<XMLSimplifyTypes#>> is an optimization pass for the <<XML#>> |
| 4 |
<<IntermediateLanguage#>>, invoked from <<XMLSimplify#>>. |
| 5 |
|
| 6 |
== Description |
| 7 |
|
| 8 |
This pass simplifies types in an <<XML#>> program, eliminating all |
| 9 |
unused type arguments. |
| 10 |
|
| 11 |
== Implementation |
| 12 |
|
| 13 |
* https://github.com/MLton/mlton/blob/master/mlton/xml/simplify-types.sig[`simplify-types.sig`] |
| 14 |
* https://github.com/MLton/mlton/blob/master/mlton/xml/simplify-types.fun[`simplify-types.fun`] |
| 15 |
|
| 16 |
== Details and Notes |
| 17 |
|
| 18 |
It first computes a simple fixpoint on all the `datatype` declarations |
| 19 |
to determine which `datatype` `tycon` args are actually used. Then it |
| 20 |
does a single pass over the program to determine which polymorphic |
| 21 |
declaration type variables are used, and rewrites types to eliminate |
| 22 |
unused type arguments. |
| 23 |
|
| 24 |
This pass should eliminate any spurious duplication that the |
| 25 |
<<Monomorphise#>> pass might perform due to phantom types. |