Skip to content

Commit 30706e0

Browse files
committed
Merge pull request #39 from hdgarrood/update-docs
Update docs for `any` and `all`
2 parents c128235 + 281d8bc commit 30706e0

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

docs/Data/Foldable.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,21 +178,23 @@ The disjunction of all the values in a data structure. When specialized
178178
to `Boolean`, this function will test whether any of the values in a data
179179
structure is `true`.
180180

181-
#### `any`
181+
#### `all`
182182

183183
``` purescript
184-
any :: forall a b f. (Foldable f, BooleanAlgebra b) => (a -> b) -> f a -> b
184+
all :: forall a b f. (Foldable f, BooleanAlgebra b) => (a -> b) -> f a -> b
185185
```
186186

187-
Test whether a predicate holds for any element in a data structure.
187+
`all f` is the same as `and <<< map f`; map a function over the structure,
188+
and then get the conjunction of the results.
188189

189-
#### `all`
190+
#### `any`
190191

191192
``` purescript
192-
all :: forall a b f. (Foldable f, BooleanAlgebra b) => (a -> b) -> f a -> b
193+
any :: forall a b f. (Foldable f, BooleanAlgebra b) => (a -> b) -> f a -> b
193194
```
194195

195-
Test whether a predicate holds for all elements in a data structure.
196+
`any f` is the same as `or <<< map f`; map a function over the structure,
197+
and then get the disjunction of the results.
196198

197199
#### `sum`
198200

src/Data/Foldable.purs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ module Data.Foldable
99
, intercalate
1010
, and
1111
, or
12-
, any
1312
, all
13+
, any
1414
, sum
1515
, product
1616
, elem
@@ -209,14 +209,16 @@ and = all id
209209
or :: forall a f. (Foldable f, BooleanAlgebra a) => f a -> a
210210
or = any id
211211

212-
-- | Test whether a predicate holds for any element in a data structure.
213-
any :: forall a b f. (Foldable f, BooleanAlgebra b) => (a -> b) -> f a -> b
214-
any p = runDisj <<< foldMap (Disj <<< p)
215-
216-
-- | Test whether a predicate holds for all elements in a data structure.
212+
-- | `all f` is the same as `and <<< map f`; map a function over the structure,
213+
-- | and then get the conjunction of the results.
217214
all :: forall a b f. (Foldable f, BooleanAlgebra b) => (a -> b) -> f a -> b
218215
all p = runConj <<< foldMap (Conj <<< p)
219216

217+
-- | `any f` is the same as `or <<< map f`; map a function over the structure,
218+
-- | and then get the disjunction of the results.
219+
any :: forall a b f. (Foldable f, BooleanAlgebra b) => (a -> b) -> f a -> b
220+
any p = runDisj <<< foldMap (Disj <<< p)
221+
220222
-- | Find the sum of the numeric values in a data structure.
221223
sum :: forall a f. (Foldable f, Semiring a) => f a -> a
222224
sum = foldl (+) zero

0 commit comments

Comments
 (0)