
On Di, 2016-02-16 at 23:02 -0800, M Farkas-Dyck wrote:
I quietly posted this library to Hackage nearly a year ago, but lately learned that some seeking such a package had difficulty finding it, so i announce it now ☺
https://hackage.haskell.org/package/filtrable
class Functor f => Filtrable f where mapMaybe :: (a -> Maybe b) -> f a -> f b catMaybes :: f (Maybe a) -> f a filter :: (a -> Bool) -> f a -> f a
For laws, see docs on Hackage.
This looks very similar to the Witherable class from https://hackage.haskell.org/package/witherable : class Traversable t => Witherable t where wither :: Applicative f => (a -> f (Maybe b)) -> t a -> f (t b) wither f = fmap catMaybes . T.traverse f mapMaybe :: (a -> Maybe b) -> t a -> t b mapMaybe = mapMaybeOf wither catMaybes :: t (Maybe a) -> t a catMaybes = catMaybesOf wither filterA :: Applicative f => (a -> f Bool) -> t a -> f (t a) filterA = filterAOf wither filter :: (a -> Bool) -> t a -> t a filter = filterOf wither