Monomorphize, was: Re: Proposal for generalized function partitionin List-library

Bernard James POPE bjpop@cs.mu.OZ.AU
Fri, 18 May 2001 19:30:38 +1000 (EST)


Lennart wrote:

> This is true in theory, but in practice most polymorphism can be removed
> by inlining.  I'm sure some pragmatic solution with limited inlining would
> work quite well.  You'd still need to be able to handle polymorphism without
> inlining, of course, so you could cope with the exceptional cases.
> 
> Mark Jones did some experiments with this kind of inlining that worked very well.
> 
>     -- Lennart

The MLton compiler (http://www.clairv.com/MLton/) uses whole program
compilation and monomorphises ML code (again they do not have to deal with
potential polymorhpic recursion, but as Lennart says, it can be treated 
as a special case in Haskell). I have never used it though, so I can't vouch for
its performance. They are motivated to use unboxed representations and so on.

The danger with whole program compilation is long compile times. But it
might be possible to allow separate compilation for development and put
up with the overheads of boxed representations and so on, but get
the benefits of the optimisations flowing from whole program compilation
when needed (ie released binaries). Sounds like a lot of work to me though.

Bernie.