The dreaded M-R

Philippa Cowderoy flippa at flippac.org
Fri Jan 27 19:55:16 EST 2006


On Sat, 28 Jan 2006, 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, 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.
> 

Is there any reason in that particular case that the dictionary transform 
can't produce something like this:

f x d = e' + e'
      where e d = very_expensive_polymorphic_function x d
            e' = e d

? What's the pathological case that prevents this applying more generally?

-- 
flippa at flippac.org

Performance anxiety leads to premature optimisation


More information about the Haskell-prime mailing list