sanctuary-js / sanctuary

:see_no_evil: Refuge from unsafe JavaScript
https://sanctuary.js.org
MIT License
3.03k stars 94 forks source link

strmap: add S.value #612

Closed davidchambers closed 5 years ago

davidchambers commented 5 years ago

Closes #611

Please let me know if you prefer lookup or some other name.

/cc @daaaaa

Bradcomp commented 5 years ago

The code looks good.

I think I may prefer lookup over value, but not strongly. value just seems really ambiguous. We are in a little pickle because our current names aren't consistent: get - verb: would suggest lookup as the closest analogue prop - noun: would suggest value as the closest analogue

davidchambers commented 5 years ago

Thank you for your feedback, @Bradcomp. :)

I think I may prefer lookup over value, but not strongly. value just seems really ambiguous.

Does seeing the types of value and values together change your perspective?

value  :: String -> StrMap a -> Maybe a
values ::           StrMap a -> Array a

I see this function as the singular of S.values, so value seems natural to me. I agree that value is not descriptive, but neither is values. :rofl:

Although naming is an important aspect of API design, even nondescriptive names eventually become meaningful through association. S.ap, anyone? :)

Does anyone wish to further support lookup? I am open to having my mind changed.