Proposal: add 'findLess' and variants to containers

Milan Straka fox at
Sat Feb 18 11:46:51 CET 2012


> Thanks for the benchmark. In light of this and your other arguments I
> think we should add the functions. Lets settle on the names. I
> currently dislike that we have 'lookup' and 'findDefault' (which is
> lookup with a default value.) We should agree on a principle for when
> we use the two words.

We should definitely settle on the names.

At some point I thought maybe we could add just these two functions:

  predecessor :: Ord a => a -> Set a -> Maybe a
  successor :: Ord a => a -> Set a -> Maybe a

These functions work like findLess, findGreater, i.e., they return
a strict predecessor or successor of a given key. The key does not need
to exist in the set/map.

Are there any good use cases for findLessEqual/findGreaterEqual,
instead of calling lookup and if it fails, call predecessor/successor?


More information about the Libraries mailing list