Skip to content

Commit b17994e

Browse files
committed
Added filterM comment
1 parent 4650b6c commit b17994e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,12 @@ unless :: forall m. (Monad m) => Boolean -> m Unit -> m Unit
303303
filterM :: forall a m. (Monad m) => (a -> m Boolean) -> [a] -> m [a]
304304
```
305305

306+
Filter where the predicate returns a monadic Boolean. For example:
307+
308+
```purescript
309+
powerSet :: forall a. [a] -> [[a]]
310+
powerSet = filterM (const [true, false])
311+
```
306312

307313

308314
## Module Control.MonadPlus

src/Control/Monad.purs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ unless :: forall m. (Monad m) => Boolean -> m Unit -> m Unit
1919
unless false m = m
2020
unless true _ = return unit
2121

22+
-- | Filter where the predicate returns a monadic Boolean. For example:
23+
-- |
24+
-- | ```purescript
25+
-- | powerSet :: forall a. [a] -> [[a]]
26+
-- | powerSet = filterM (const [true, false])
27+
-- | ```
2228
filterM :: forall a m. (Monad m) => (a -> m Boolean) -> [a] -> m [a]
2329
filterM _ [] = return []
2430
filterM p (x:xs) = do

0 commit comments

Comments
 (0)