[Haskell-cafe] [announcement] filtrable: class of filtrable containers

David Menendez dave at zednenem.com
Wed Feb 17 17:26:01 UTC 2016

On Wed, Feb 17, 2016 at 2:02 AM, M Farkas-Dyck <m.farkasdyck at gmail.com>

> 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 is something I’ve made for myself once or twice (I called it

One law I didn’t notice you mention is:

mapMaybe f . mapMaybe g = mapMaybe (f <=< g)

In other words, mapMaybe is a functor from the Kleisli category over Maybe
to Hask. (This may come free from parametricity and mapMaybe Just = id.)

Dave Menendez <dave at zednenem.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160217/f91cab5b/attachment.html>

More information about the Haskell-Cafe mailing list