Skip to content

Generalize functions from Data.Maybe (‘catMaybes’, ‘mapMaybe’)

Opening a ticket for discussion. As mentioned in this comment, more functions can be generalized to Foldable

catMaybes   :: Foldable f => f (Maybe a) -> [a]
mapMaybe    :: Foldable f => (a -> Maybe b) -> (f a -> [b])
listToMaybe :: Foldable f => f a -> Maybe a

I think catMaybes and mapMaybe are fine candidates. The comment offers more extreme changes,

catMaybes :: (Foldable f, Foldable g) => f (g a) -> [a]
mapMaybe  :: (Foldable f, Foldable g) => (a -> f b) -> (f a -> [b])
Edited by Icelandjack
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information