-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should localeCompare
return in Effect
?
#169
Comments
I agree, this does seem like it should be in |
I confirmed with the |
I could make a PR to update the type here (along with the docs and tests), but looking at the rest of the library, this would be the first use of Tracking down when |
Well it's still useful when passed a locale explicitly. Maybe just require the locale parameter? Or is there maybe a more appropriate module for locale-sensitive operations to live in? |
I've been working on bindings for the locale-sensitive operations specified in ECMA 402 here: https://github.com/pete-murphy/purescript-js-intl/tree/main/src/JS/LocaleSensitive. From what I remember of last time I looked, I couldn't find any other references to any of those functions on Pursuit aside from this library's
What's the type of the locale parameter? If it's "a".localeCompare("b", "zzzz") // throws a RangeError Even if it were a well-typed |
That's a good point. Then I support dropping it or moving it to another more appropriate place. |
I think it seems reasonable to drop it here 👍 |
localeCompare
can return different output depending on locale. Example borrowed from MDN:The FFI for
Data.String.Common.localeCompare
uses the system default locale, soData.String.Common.localeCompare "ä" "z"
could beLT
orGT
depending on if it's run in Germany or Sweden, for example.It seems unlikely (maybe even impossible? I'm not sure) for a system's locale to change over the lifetime of a program, so maybe that is enough to consider
localeCompare
observationally pure?I'm mostly just curious about the intuition for what makes FFI code "effect"-ful, as I have a library of bindings for the
Intl
object and I was planning on adding to it alocaleCompare
that accepted theLocale
argument as well.The text was updated successfully, but these errors were encountered: