unisonweb / base_v1

Unison base libraries, published using V1 codebase format
24 stars 14 forks source link

base.Search.indexOf is misnamed should be anyIndexOf #3

Closed raam86 closed 4 years ago

raam86 commented 4 years ago

indexOf is expected to find the first index on the given value while unison provides the index of the first value encountered in a binary search :

 test> tests.http.utils.indexof.happy = run (expect ((base.Search.indexOf 1 [1,1]) == Some 0))

  :no_entry_sign: FAILED

In Haskell:

   Data.List.elemIndex 1 [1,1]
=> Just 0

Suggestion would be to change the function name to anyIndexOf and adding a simple indexOf function to List

pchiusano commented 4 years ago

Fixed in https://github.com/unisonweb/base/commit/18aa864dc6b34fdb941c45f93c55745aac588d45

I think the Search functions could also use tests, docs, and examples though.