<div dir="ltr">Oops disregard that. TheĀ <span style="font-size:12.8px">mapMaybeWithKey doesn't quite do what I expected.</span></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Nov 6, 2015 at 6:43 PM, Lyndon Maydwell <span dir="ltr"><<a href="mailto:maydwell@gmail.com" target="_blank">maydwell@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Well, this might not be the most efficient, but:<div><br></div><div>mapKeysMaybe f = Data.Map.mapMaybeWithKey (const . f)</div><div><br></div><div><br></div><div>What do you reckon?</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Fri, Nov 6, 2015 at 6:29 PM, Dennis Raddle <span dir="ltr"><<a href="mailto:dennis.raddle@gmail.com" target="_blank">dennis.raddle@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">Can someone give me a clever way to implement mapKeysMaybe, defined as follows?<div><br></div><div>Ord k => (k -> Maybe k) -> Map k a -> Map k a</div><div><br></div><div>where the transformed keys that evaluate to Just are the only ones kept?</div><div><br></div><div>I am thinking this will probably help me understand a new type, like traversable or something.</div><div><br></div></div>
<br></div></div>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>