
Oleg Lobachev
#else and [] = True and (x:xs) = x && and xs or [] = False or (x:xs) = x || or xs
{-# RULES
"and/build" forall (g::forall b.(Bool->b->b)->b->b) .
and (build g) = g (&&) True
"or/build" forall (g::forall b.(Bool->b->b)->b->b) .
or (build g) = g (||) False
#-} #endif
Is there any reason for that besides some clever optimizations? I am particularly interested in the behavior of and for infinite lists and these two versions are equivalent in this aspect.
Precisely for clever optimisations. See the paper "A Short Cut to Deforestation" by Andrew Gill, John Launchbury and Simon Peyton Jones (from 1993 apparently; I'm going off a copy I have locally). -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com