<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi, Sean,<div class=""><br class=""></div><div class="">I guess that’s why there is a disclaimer:</div><div class=""><br class=""></div><div class="">   “If this is **also** a Foldable, then”</div><div class=""><br class=""></div><div class="">Another similar example is `Hashable` which doesn’t require things to be `Eq`, yet states the infectivity law.</div><div class=""><br class=""></div><div class="">- Oleg</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 17 Feb 2016, at 10:50, Sean Leather <<a href="mailto:sean.leather@gmail.com" class="">sean.leather@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi Joachim,<div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Feb 17, 2016 at 10:32 AM, Joachim Breitner wrote:<br class=""><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 class="">
> I quietly posted this library to Hackage nearly a year ago, but lately<br class="">
> learned that some seeking such a package had difficulty finding it, so<br class="">
> i announce it now ☺<br class="">
><br class="">
> <a href="https://hackage.haskell.org/package/filtrable" rel="noreferrer" target="_blank" class="">https://hackage.haskell.org/package/filtrable</a><br class="">
><br class="">
> class Functor f => Filtrable f where<br class="">
>     mapMaybe :: (a -> Maybe b) -> f a -> f b<br class="">
>     catMaybes :: f (Maybe a) -> f a<br class="">
>     filter :: (a -> Bool) -> f a -> f a<br class="">
><br class="">
> For laws, see docs on Hackage.<br class="">
<br class="">
</span>You might want to add laws in the style of <br class="">
<br class="">
    If this is also a Foldable, then <br class="">
       toList . mapMaybe f = mapMapybe f . toList<br class="">
       toList . catMaybes = catMaybes . toList<br class="">
       toList . filter f = filter f . toList<br class="">
<br class="">
which would fix the behavior quite tightly.<br class=""></blockquote><div class=""><br class=""></div><div class="">Why would you specify laws for Filtrable w.r.t. Foldable, when Foldable is not part of the definition?</div><div class=""><br class=""></div><div class="">There is at least one potential application for Filtrable for a type that isn't a Foldable:</div><div class=""><br class=""></div><div class="">  <a href="https://github.com/reflex-frp/reflex/pull/44" class="">https://github.com/reflex-frp/reflex/pull/44</a><br class=""></div><div class=""><br class=""></div><div class="">Regards,</div><div class="">Sean</div></div></div></div>
_______________________________________________<br class="">Haskell-Cafe mailing list<br class=""><a href="mailto:Haskell-Cafe@haskell.org" class="">Haskell-Cafe@haskell.org</a><br class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe<br class=""></div></blockquote></div><br class=""></div></body></html>