and / or

Simon Peyton Jones simonpj at microsoft.com
Tue Aug 19 07:07:27 UTC 2014


| First question: how bad would it be to use the Prelude definitions of
| and and or? I assume if there's a problem it's probably excessive
| duplication by the inliner?
| 
| Second question: if that would be bad, why not rewrite them to foldr
| forms, then write them back, like other things do?

I think it'd be fine to use foldr.

Rewriting back to and/or is probably good when fusion doesn't happen, to avoid duplicating the loop at every call site.

| Oh, I see now. If it doesn't fuse, it performs extra operations,
| because we want foldr1 rather than foldr, and foldr1 is not so nice for
| fusion.

I don't understand that at all.  I see no foldr1 in the current impl of and/or.

Simon


More information about the Libraries mailing list