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

martin monkleyon at googlemail.com
Thu Feb 18 02:57:36 UTC 2016


The only need for the functor requirement is in the default definition
of mapMaybe - so why not drop it?

I would also suggest you add (modulo better names)

partition :: (a -> Bool) -> f a -> (f a , f a)
partitionWith :: (a -> Either b c) -> f a -> (f b, f c)
catEithers :: f (Either b c) -> (f b, f c)
lefts :: f (Either b c) -> f b
rights :: f (Either b c) -> f c

I think the class would still be equivalent to your current one, but
more useful.

On 2016-02-17 08:02, 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.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list