[MLton] improved overloading for SML

Stephen Weeks MLton@mlton.org
Mon, 17 Oct 2005 22:22:58 -0700


> Would it be possible to give MLton an interface (an extension) that
> would allow you to query information related to optimizations?

I suppose so.  MLton can already track source information all the way
through to code generation.  The real difficulty is in designing a
query language with broad enough applicability and a somewhat
understandable semantics.  I don't have many thoughts there.

Given MLton's (lack of) speed, a reasonable approach might be to have
a flag that causes MLton to gather all the information it can about
optimizations while it runs, which it thenspits out to a file.  Then,
have tool that lets one explore the results and ask as many queries as
one wants after the fact.  Perhaps there might even be a human
readable output format providing a concise summary, making the query
language less necessary.

> From a pragmatic point-of-view, this is one of the things that I
> think is more straightforward with macros and "generative
> programming". You can construct your code in such a way that
> redundant code never reaches the backend of the compiler. When you
> use combinator libraries, you can (almost) never (easily) be sure
> that the compiler is doing what you think it should be doing.

Good point.  I've always liked the aspect of multi-level systems that
one has a good understanding of what gets done at compile time.
That's one reason why I like MLton's defunctorization and
monomorphisation so much.  They are very simple to understand (the
automatic phantom type elimination notwithstanding :-).