-
Notifications
You must be signed in to change notification settings - Fork 157
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
Make Data.Text.replace
total
#425
Comments
I'm sympathetic to the idea, but technically this is a breaking change. |
@sol could you please gather community feedback on this change? |
@Bodigrim I would love to help, however, even if I try hard, I'll not be able to free up time to mediate this issue. If somebody else wants to pick it up, this might be useful: The reason why I think this change is a net positive is that relying on the semantics of pure exceptions is inherently risky: https://gitlab.haskell.org/ghc/ghc/-/issues/1171 Read: If your program relies on the type of pure exceptions, it may produce different results depending on GHC version and optimization level. For that reason some people will advice that you should only ever use a partial function if you make sure that your input will not trigger an exception. Observations:
|
This is a very benign breaking change. People push back against changes that cause unnecessary churn, but nobody depends on I've confirmed that every occurrence of
|
I've noticed that I think it might be reasonable to make There's also |
For comparison,
So I would suggest either making all of these total (my preference) or at least copying |
Data.Text.replace
errors if the needle is the empty string. Every other implementation I tried matches the empty string against every position in the string. I suggest that for consistency with other languages and to avoiding partiality we adopt that behavior.Expected behavior:
Actual behavior:
Rust:
$ rustc main.rs && ./main xfxoxox
Python:
JavaScript:
The text was updated successfully, but these errors were encountered: