The dreaded M-R
Benjamin Franksen
benjamin.franksen at bessy.de
Fri Jan 27 20:50:05 EST 2006
On Saturday 28 January 2006 01:13, Twan van Laarhoven wrote:
> Benjamin Franksen wrote:
> > My personal opinion is that it should be exactly the other way
> > around:
> >
> > All normal bindings (i.e. using '=') should be as polymorphic and
> > general as possible.
>
> Do you mean *all* bindings,
Yes.
> or only top-level ones? If you really
> mean
>
> all, wouldn't e be polymorphic (with type Num a=>a) in, say:
> > f x = e + e
> > where e = very_expensive_polymorphic_function x
>
> That would be a Very Bad Thing.
Why? The compiler /might/ be able to decide that 'f' is in fact used
only monomorphically and thus 'e' can be shared. Even if 'f' is
exported (in which case I would most probably write a signature at one
time), a compiler that does whole-program analysis can find out. It
could even specialize 'f' for each type at which it is used, each
specialized version being monomorphic, internally, so that 'e' can be
'maximally shared'.
If all else fails, you can always change it to := (or whatever other
symbol will be agreed upon) if you want to indicate to the
compiler/interpreter: "I'd rather get an error message if I use this
polymorphically/overloaded/whatever. This 'e' must be shared at all
costs!".
Cheers,
Ben
More information about the Haskell-prime
mailing list