On Thu, 13 May 1999, Simon Peyton-Jones wrote:

> I'm not sure exactly what you are asking here.
> > For example, in   {rules  (map f).(map g) = map (f.g) }
> >                   f xs = let  g = ...
> >                               h = ...
> >                               h1 = map g
> >                               h2 = map h  
> >                          in   h1 (h2 xs)
> > the rule can do nothing with the source program. 
> 
> You are right -- h1 (h2 xs) doesn't match the rule.  But if the compiler
> substitutes (map g} for h1, and (map h) for h2, then the rule will match.
> If h1,h2 are (a) big and (b) used several times, then this substitution
> won't happen.  That's important, because if (a) and (b) are true then
> applying the rule would lose sharing, all the more so if (c) h1 or h2
> is a redex.

Are ($) and (.) actually treated specially within ghc then and optimized
away from the rules? If so then rule rewriting becomes more powerful than
I'd thought, beacuse the one of the problems I thought was there was that
the idea that `several maps can be be turned into a single map of several
applied functions' has many syntactic realisations, of which (map f).(map
g) = map (f.g) is what everyone remembers because it's the most elegant,
whereas the compiler may see some subtle variation of expression which
doesn't affect the basic idea but would be missed by a simple `textual'
matching.

___cheers,_dave______________________________________________________
email: [EMAIL PROTECTED]       "`What sort of people would we be if
www.cs.bris.ac.uk/~tweed/pi.htm    we didn't go into the Library?'
work tel: (0117) 954-5253         `Students.' -- Terry Pratchett



Reply via email to