on master help sign in
Make `and`, `or`, `any`, and `all` short-circuit from left-to-right, as is more natural.
475eb57bmsherman
libs/prelude/Prelude/Foldable.idr+4−4
@@ -21,16 +21,16 @@ concatMap : (Foldable t, Monoid m) => (a -> m) -> t a -> m
21concatMap f = foldr ((<+>) . f) neutral
21concatMap f = foldr ((<+>) . f) neutral
22
22
23and : Foldable t => t (Lazy Bool) -> Bool
23and : Foldable t => t (Lazy Bool) -> Bool
24−and = foldr (flip (&&)) True
24+and = foldl (&&) True
25
25
26or : Foldable t => t (Lazy Bool) -> Bool
26or : Foldable t => t (Lazy Bool) -> Bool
27−or = foldr (flip (||)) False
27+or = foldl (||) False
28
28
29any : Foldable t => (a -> Bool) -> t a -> Bool
29any : Foldable t => (a -> Bool) -> t a -> Bool
30−any p = foldr (flip (||) . Delay . p) False
30+any p = foldl (\x => \y => x || p y) False
31
31
32all : Foldable t => (a -> Bool) -> t a -> Bool
32all : Foldable t => (a -> Bool) -> t a -> Bool
33−all p = foldr (flip (&&) . Delay . p) True
33+all p = foldl (\x => \y => x && p y) True
34
34
35sum : (Foldable t, Num a) => t a -> a
35sum : (Foldable t, Num a) => t a -> a
36sum = foldr (+) 0
36sum = foldr (+) 0