map does not evaluate all its arguments before and . And and shorted.
Note that in GHC all is not really defined like that.
-- | Applied to a predicate and a list, 'all' determines if all elements -- of the list satisfy the predicate. all :: (a -> Bool) -> [a] -> Bool
We see that all p (x:xs) = px && all p xs , so whenever the px is false, the evaluation stops.
In addition, there is an all/build simplification rule that effectively converts your all p [1..max] into a simple fault-tolerant loop *, so I donβt think you can significantly improve the modification of all .
*. Simplified code should look like this:
eftIntFB cn x0 y | x0 ># y = n | otherwise = go x0 where go x = I# x `c` if x ==# y then n else go (x +# 1#) eftIntFB ((&&) . p) True 1# max#
kennytm
source share