<div dir="ltr">On Wed, Feb 17, 2016 at 2:02 AM, M Farkas-Dyck <span dir="ltr"><<a href="mailto:m.farkasdyck@gmail.com" target="_blank">m.farkasdyck@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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></blockquote><div><br></div><div>This is something I’ve made for myself once or twice (I called it “Siftable”).</div><div><br></div><div>One law I didn’t notice you mention is:</div><div><br></div><div>mapMaybe f . mapMaybe g = mapMaybe (f <=< g)</div><div><br></div><div>In other words, mapMaybe is a functor from the Kleisli category over Maybe to Hask. (This may come free from parametricity and mapMaybe Just = id.)</div></div><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Dave Menendez <<a href="mailto:dave@zednenem.com" target="_blank">dave@zednenem.com</a>><br><<a href="http://www.eyrie.org/~zednenem/" target="_blank">http://www.eyrie.org/~zednenem/</a>></div>
</div></div>