
Hi, Sean, I guess that’s why there is a disclaimer: “If this is **also** a Foldable, then” Another similar example is `Hashable` which doesn’t require things to be `Eq`, yet states the infectivity law. - Oleg
On 17 Feb 2016, at 10:50, Sean Leather
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 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:
https://github.com/reflex-frp/reflex/pull/44 https://github.com/reflex-frp/reflex/pull/44
Regards, Sean _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe