good fusion (was Re: inits)

Udo Stenzel u.stenzel at web.de
Mon Apr 10 11:45:42 EDT 2006


Malcolm Wallace wrote:
> {-# RULES
> "foldr2/both"   forall k z (g::forall c.(a->c->c)->c->c)
>                            (h::forall c.(b->c->c)->c->c) . 
>     foldr2 f z (build g) (build h) =
>         g (\x _-> h (\y r-> f x y r) z) z
> #-}

Looks wrong to me.  Somehow it doesn't feel right that the first
argument to g doesn't use its sencond argument and I think, what you
wrote is actually

	foldr (f (head (build g))) z (build h)

or something like that.  Wasn't there some consensus that foldr/build
cannot deforest both lists that go into zip?  Intuitively it feels
right: the "loop" that drives the calculation is contained in the build,
and it cannot call out to the other generator to just get one element.


Udo.
-- 
"The key to performance is elegance, not battalions of special cases."
	-- Jon Bentley and Doug McIlroy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org//pipermail/libraries/attachments/20060410/1c47bade/attachment.bin


More information about the Libraries mailing list