Skip to content

Commit 9772fb2

Browse files
committed
Merge pull request #6 from purescript/cat-maybes
Add catMaybes
2 parents 679d176 + 4c347fd commit 9772fb2

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
append :: forall a. [a] -> [a] -> [a]
2727

28+
catMaybes :: forall a. [Maybe a] -> [a]
29+
2830
concat :: forall a. [[a]] -> [a]
2931

3032
concatMap :: forall a b. (a -> [b]) -> [a] -> [b]

src/Data/Array.purs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module Data.Array
99
, null
1010
, map
1111
, mapMaybe
12+
, catMaybes
1213
, length
1314
, findIndex
1415
, findLastIndex
@@ -218,6 +219,9 @@ foreign import map
218219
mapMaybe :: forall a b. (a -> Maybe b) -> [a] -> [b]
219220
mapMaybe f = concatMap (maybe [] singleton <<< f)
220221

222+
catMaybes :: forall a. [Maybe a] -> [a]
223+
catMaybes = concatMap (maybe [] singleton)
224+
221225
foreign import filter
222226
"function filter (f) {\
223227
\ return function (arr) {\

0 commit comments

Comments
 (0)