[MLton] improved overloading for SML

Stephen Weeks MLton@mlton.org
Mon, 17 Oct 2005 17:31:42 -0700


> Are you familiar with G'Caml?
> 
>   http://pauillac.inria.fr/~furuse/generics/
> 
> I have not yet read any G'Caml papers, but the G'Caml examples and this
> approach for overloading in SML seem to (my eyes) have some resemblance.
> It would be interesting to know how much of G'Caml can be expressed using
> this approach.

I've not looked into it before, but I am now.  It is certainly
inspiring me to extend the approach.  I just sent a mail on
implementing typecase, and I have an idea how to do typerec (by giving
up on the guarantee of completely static resolution).

I have skimmed through

  http://pauillac.inria.fr/~furuse/publications/jfla2001.ps.gz

Let me know if you've found other of those papers useful.

> While compiling the Test functor I noticed that the Num signature omits:
> 
>       val toString: 'a t -> string

Whoops.  I reworked things at the last minute and left that out.

> Hmm... Would it possible to do a separate pass before xmlSimplifyTypes to
> detect this sort of thing and introduce the unnecessary uses of the type
> variables or otherwise tell xmlSimplifyTypes not to eliminate some type
> variables? (I have no idea of how to that. I'm just thinking out loud.)

xmlSimplifyTypes was originally written exactly for the purpose of
eliminating unused phantom types.  The thinking at the time was that
phantom types were not a good hint as what should be duplicated, and
leaving them around would lead to excessive code duplication by the
monomorphiser.  As I've seen more uses of phantom types, especially
this one, that is becoming less clear.  In any case, I don't have any
good heuristics on which phantom types are useful to keep and which
aren't.  So I don't know how to tweak xmlSimplifyTypes.  It's easy
enough for now while we're still learning to turn it off, either for
the whole program or on a case-by-case basis by tricking MLton.