I'm as excited about the possibility of a limited form of compile time
evaluation via rewrite rules but I'm a getting a bit worried that no-one
has made any examples where there's an laziness to consider: I really
wouldn't want semantic differences depending on the degree of optimization
I compile with.
For example, one of Sergey's rules was
x*(inv x) = unity
Assuming that his group has some sub-structure (e.g., considering
polynomials as a group) so that there's an algorithm involved in computing
* which requires evaluating x, then when evaluated via Haskell's rules,
x*(inv x) where x=bottom
is bottom whereas under term rewriting optimization it is unity. I'm sure
if I gave it more thought I could come up with a realistic programming
example, rather than a mathematical one.
Even if it doesn't affect the actual result it may dramatically affect the
size of expressions held temporarily, eg
tipsOfTheDay
= map addCopyrightLogo (map toUppercase (map addHaveANiceDay
[tip1,tip2,tip3,........,tip_n]))
will, if I understand correctly, transform given the rules
generally envisaged
map f . map g ==> map (f.g)
map f (x:xs) ==> f x:map f xs
into
tipsOfTheDay=[addCopyrightLogo(toUppercase(addHaveANiceDay tip1)),......
addCopyrightLogo(toUppercase(addHaveANiceDay tip_n))]
even if n is 1000 but only three or four tips are ever actually used in
the program, with the consequent increase in the number of closures
stored. The fact that the map rule was written with the intention of
applying in situations like
f xs=sum(map (^2) (12:xs))
doesn't stop it being applied in only situations like the above.
(This is a very contrived example, but I have
written similar code only to later hand-optimize it away by rewriting
the nested maps to use a single map & function composition.)
Has anyone any thoughts on this? Is it actually a non-issue?
___cheers,_dave______________________________________________________
email: [EMAIL PROTECTED] "Someday, even toasters will have
www.cs.bris.ac.uk/~tweed/pi.htm monads in them thanks to Haskell."
work tel: (0117) 954-5253 M P Jones (allegedly)