Discussion: lookups in maps

Andreas Abel andreas.abel at ifi.lmu.de
Tue Jun 9 09:18:40 UTC 2020


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 am quite happy with writing stuff like

    fromMaybe d $ Map.lookup k m

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


More information about the Libraries mailing list