
John Meacham wrote:
An optimization that jhc implements which should be portable to other compilers is the 'type analysis' pass. it does a fixpoint iteration to determine every possible type every polymorhpic value is called at and then goes through and specializes all that are called at exactly one type, which is a surprisingly large amount. This is tied to the monomorphism restriction in that given foo :: Num a . a which is only used as an Int, should I turn it into a caf or give it a phantom argument to prevent sharing? I have not made up my mind on the issue...
I think most compilers have had this kind of option for quite a while. But how well works depends on the scope of it. With separate compilation (that really generates code) you can't really do it very well. Another (small) complication is that your the fixpoint iteration doesn't necessarily terminate. So you need a backup strategy. -- Lennart