<div dir="ltr">Hi Joachim,<div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 17, 2016 at 10:32 AM, Joachim Breitner wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">Am Dienstag, den 16.02.2016, 23:02 -0800 schrieb M Farkas-Dyck:<br>
> I quietly posted this library to Hackage nearly a year ago, but lately<br>
> learned that some seeking such a package had difficulty finding it, so<br>
> i announce it now ☺<br>
><br>
> <a href="https://hackage.haskell.org/package/filtrable" rel="noreferrer" target="_blank">https://hackage.haskell.org/package/filtrable</a><br>
><br>
> class Functor f => Filtrable f where<br>
>     mapMaybe :: (a -> Maybe b) -> f a -> f b<br>
>     catMaybes :: f (Maybe a) -> f a<br>
>     filter :: (a -> Bool) -> f a -> f a<br>
><br>
> For laws, see docs on Hackage.<br>
<br>
</span>You might want to add laws in the style of <br>
<br>
    If this is also a Foldable, then <br>
       toList . mapMaybe f = mapMapybe f . toList<br>
       toList . catMaybes = catMaybes . toList<br>
       toList . filter f = filter f . toList<br>
<br>
which would fix the behavior quite tightly.<br></blockquote><div><br></div><div>Why would you specify laws for Filtrable w.r.t. Foldable, when Foldable is not part of the definition?</div><div><br></div><div>There is at least one potential application for Filtrable for a type that isn't a Foldable:</div><div><br></div><div>  <a href="https://github.com/reflex-frp/reflex/pull/44">https://github.com/reflex-frp/reflex/pull/44</a><br></div><div><br></div><div>Regards,</div><div>Sean</div></div></div></div>