
Andreas Abel
lurkup is essentially lookup returning a CPS-version (Church encoding) of Maybe a.
type CMaybe a = forall r. r -> (a -> r) -> r lurkup' :: k -> Map k a -> CMaybe a
Is it worth to add a new name for this (above the Fairbairn threshhold)?
I don’t think so :-)
I am quite happy with writing stuff like
fromMaybe d $ Map.lookup k m
There might be a case for a flipped infix version of this. I see that there are several in various libraries including `orElse` and (?:) more than once.
On 2020-06-08 21:07, David Feuer wrote:
lurkup :: Ord k => r -> (a -> r) -> k -> Map k a -> r lurkup r f k = maybe r f . lookup k
Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
-- Jón Fairbairn Jon.Fairbairn@cl.cam.ac.uk