<div dir="auto"><div>I know I've had cases where I didn't have a good default `a` but did have an `r` (and I wanted to apply a function to the result if there was a value in the Map anyway).<br><br><div data-smartmail="gmail_signature"><br>On mobile; please excuse any tpyos.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 9 Jun 2020, 5:49 am Oliver Charles, <<a href="mailto:ollie@ocharles.org.uk">ollie@ocharles.org.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u><div><div>Could you share why you are more enthusiastic about such a function?</div><div><br></div><div>On Mon, 8 Jun 2020, at 8:07 PM, David Feuer wrote:<br></div><blockquote type="cite" id="m_4461777459380372191qt"><div dir="auto"><div>Discussion has gotten going again about harmonizing between the names findWithDefault and lookupDefault in containers and unordered-containers:<br></div><div dir="auto"><br></div><div dir="auto"> findWithDefault :: Ord k<br></div><div dir="auto"> => a -> k -> Map k a -> a<br></div><div dir="auto"> lookupDefault :: (Eq k, Hashable k)<br></div><div dir="auto"> => a -> k -> HashMap k a -> a<br></div><div dir="auto"><br></div><div dir="auto">I've been fairly unenthusiastic about adding extra names for this function in one package or the other, in large part because I don't like the function. I'd much rather have something in the spirit of `either`, `maybe`, `bool`, etc.:<br></div><div dir="auto"><br></div><div dir="auto"> lurkup :: Ord k<br></div><div dir="auto"> => r -> (a -> r) -> k -> Map k a -> r<br></div><div dir="auto"> lurkup r f k = maybe r f . lookup k<br></div><div dir="auto"> lookup k = lurkup Nothing Just k<br></div><div dir="auto"><br></div><div dir="auto">Unfortunately, I haven't been able to come up with a decent name for this function. Can anyone help?<br></div></div><div>_______________________________________________<br></div><div>Libraries mailing list<br></div><div><a href="mailto:Libraries@haskell.org" target="_blank" rel="noreferrer">Libraries@haskell.org</a><br></div><div><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" target="_blank" rel="noreferrer">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br></div><div><br></div></blockquote></div>_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank" rel="noreferrer">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</blockquote></div></div></div>