and / or

David Feuer david.feuer at gmail.com
Tue Aug 19 06:40:48 UTC 2014


On Tue, Aug 19, 2014 at 2:34 AM, David Feuer <david.feuer at gmail.com> wrote:
> 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. Whoops! That's no good! But we should take better
> advantage of the NOINLINE here with a few more rules. In particular,
> we *know* that && and || are tiny little functions, so we can inline
> them to our hearts' content:
>
> "and/cons" forall x y . and (x:xs) = x && and xs
> "or/cons"   forall x y . or (x:xs) = x || or xs

Aaaaand that's not quite right, for the same reason, and wrong names.
What we need is probably:

"and/cons"      forall x1 x2 xs . and (x1:x2:xs) = x1 && and (x2:xs)
"and/single"    forall x . and [x] = x
"or/cons"       forall x1 x2 xs . or (x1:x2:xs)  = x1 || or (x2:xs)
"or/single"     forall x . or [x] = x


More information about the Libraries mailing list