foldr -package:base

foldr, applied to a binary operator, a starting value (typically the right-identity of the operator), and a ByteString, reduces the ByteString using the binary operator, from right to left.
foldr, applied to a binary operator, a starting value (typically the right-identity of the operator), and a packed string, reduces the packed string using the binary operator, from right to left.
foldr, applied to a binary operator, a starting value (typically the right-identity of the operator), and a ShortByteString, reduces the ShortByteString using the binary operator, from right to left.
O(n) foldr, applied to a binary operator, a starting value (typically the right-identity of the operator), and a Text, reduces the Text using the binary operator, from right to left. If the binary operator is strict in its second argument, use foldr' instead. foldr is lazy like foldr for lists: evaluation actually traverses the Text from left to right, only as far as it needs to. For example, head can be defined with O(1) complexity using foldr:
head :: Text -> Char
head = foldr const (error "head empty")
Searches from left to right with short-circuiting behavior can also be defined using foldr (e.g., any, all, find, elem).
foldr, applied to a binary operator, a starting value (typically the right-identity of the operator), and a stream, reduces the stream using the binary operator, from right to left. Properties
foldr f z0 . stream = foldr f z0
O(n) foldr, applied to a binary operator, a starting value (typically the right-identity of the operator), and a Text, reduces the Text using the binary operator, from right to left. foldr is lazy like foldr for lists: evaluation actually traverses the Text from left to right, only as far as it needs to. For example, head can be defined with O(1) complexity using foldr:
head :: Text -> Char
head = foldr const (error "head empty")
Fold the values in the map using the given right-associative binary operator, such that foldr f z == foldr f z . elems. For example,
elems map = foldr (:) [] map
let f a len = len + (length a)
foldr f 0 (fromList [(5,"a"), (3,"bbb")]) == 4
Fold the elements in the set using the given right-associative binary operator, such that foldr f z == foldr f z . toAscList. For example,
toAscList set = foldr (:) [] set
Fold the values in the map using the given right-associative binary operator, such that foldr f z == foldr f z . elems. For example,
elems map = foldr (:) [] map
let f a len = len + (length a)
foldr f 0 (fromList [(5,"a"), (3,"bbb")]) == 4
Fold the elements in the set using the given right-associative binary operator, such that foldr f z == foldr f z . toAscList. For example,
toAscList set = foldr (:) [] set
O(n) Right fold.
Right fold
Right fold
O(n) Right fold.
O(n) Pure right fold.
O(n) Pure right fold.
O(n) Right fold.
O(n) Pure right fold.
O(n) Right fold.
O(n) Pure right fold.
O(n) Right fold.
O(n) Pure right fold.
Reduce this map by applying a binary operator to all elements, using the given starting value (typically the right-identity of the operator).