catmaybes -package:witherable -package:List -package:hledger -package:leancheck -package:streamly -package:event-list

The catMaybes function takes a list of Maybes and returns a list of all the Just values.

Examples

Basic usage:
>>> catMaybes [Just 1, Nothing, Just 3]
[1,3]
When constructing a list of Maybe values, catMaybes can be used to return all of the "success" results (if the list is the result of a map, then mapMaybe would be more appropriate):
>>> import Text.Read ( readMaybe )

>>> [readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ]
[Just 1,Nothing,Just 3]

>>> catMaybes $ [readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ]
[1,3]
O(n) Return a Vector of all the Just values.
Filter the Just values from a stream, discarding the Nothing values. Subject to fusion Since 0.5.1
Takes a tree of Maybes and returns a tree of all the Just values. If the root of the tree is Nothing then Nothing is returned.
Analogous to catMaybes in Data.Maybe.
The catMaybes function takes a Stream of Maybes and returns a Stream of all of the Just values. concat has the same behavior, but is more general; it works for any foldable container type.
Takes all of the Just values from a sequence of Maybe ts and concatenates them into an unboxed sequence of ts. Since 0.6.2
The catMaybes function takes a list of Maybes and returns a list of all the Just values.
Like catMaybes.
Modify a fold to receive a Maybe input, the Just values are unwrapped and sent to the original fold, Nothing values are discarded.
>>> catMaybes = Fold.mapMaybe id

>>> catMaybes = Fold.filter isJust . Fold.lmap fromJust
In a stream of Maybes, discard Nothings and unwrap Justs.
>>> catMaybes = Stream.mapMaybe id

>>> catMaybes = fmap fromJust . Stream.filter isJust
Pre-release
catMaybes xs discards the Nothings in xs and extracts the as
The catMaybes function takes a Stream of Maybes and returns a Stream of all of the Just values. concat has the same behavior, but is more general; it works for any foldable container type.
Takes a slist of Maybes and returns a slist of all the Just values.
>>> catMaybes (cons (Just 1) $ cons Nothing $ one $ Just 3)
Slist {sList = [1,3], sSize = Size 2}
Like catMaybes for type lists
Generalises the catMaybes function from lists to an arbitrary MonadPlus.
Keep only the present values, reversing the order.
Keep all Maybes and discard the Nothings.

Examples