Monomorphism restriction - is this still needed for efficiency?
Simon Marlow
simonmarhaskell at gmail.com
Mon Jun 12 05:22:36 EDT 2006
Brian Hulley wrote:
> I'm wondering if the monomorphism restriction is now just an anachronism
> from Haskell 98 or if it is still needed for efficiency ie should I just
> now use -fno-monomorphism-restriction when compiling all my code to
> consign it to the dustbin of history? :-)
>
> A related question is, if it can still improve efficiency when applied
> to local bindings, whether it would be worthwhile to have an additional
> option to switch monomorphism off for top level bindings but still keep
> it for local bindings, since I can't think of any situation where I
> don't want a top level binding to be fully polymorphic.
>
> Does anyone know of any situation where a top level binding should not
> be fully polymorphic?
The discussion on the monomorphism restriction on the haskell-prime list
recently should help you:
http://www.haskell.org//pipermail/haskell-prime/2006-February/000252.html
I measured what happened to the nofib suite with
-fno-monomorphism-restriction. The answer was, on the whole, "not
much". But there were a couple of programs that got worse.
It's a matter of personal taste whether you should use
-fno-monomorphism-restriction, I wouldn't like to emphatically declare
one way or the other which is best.
Cheers,
Simon
More information about the Glasgow-haskell-users
mailing list