On 17 Feb 2016, at 10:50, Sean Leather <sean.leather@gmail.com> wrote:Hi Joachim,_______________________________________________On Wed, Feb 17, 2016 at 10:32 AM, Joachim Breitner wrote:Am Dienstag, den 16.02.2016, 23:02 -0800 schrieb M Farkas-Dyck:
> 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.
You might want to add laws in the style of
If this is also a Foldable, then
toList . mapMaybe f = mapMapybe f . toList
toList . catMaybes = catMaybes . toList
toList . filter f = filter f . toList
which would fix the behavior quite tightly.Why would you specify laws for Filtrable w.r.t. Foldable, when Foldable is not part of the definition?There is at least one potential application for Filtrable for a type that isn't a Foldable:Regards,Sean
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe