-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add aliases for Bytes.indexOf
and Text.indexOf
#165
Comments
Bytes.indexOf
and Text.indexOf
Bytes.indexOf
and Text.indexOf
The 👊🏿 character is two codepoints, so the answer should be |
Is this a bug in the Text package?? @stew is just calling through to that... this function: https://hackage.haskell.org/package/text-2.0.2/docs/Data-Text-Internal-Lazy-Search.html Or maybe we're just using it wrong? |
If it's working as intended, I don't understand what it's doing. It's interpreting |
What if you just call it in ghci? Does it still behave incorrectly? |
Yeah
Is this just due to the fact that Haskell strings are UTF-16? |
https://hackage.haskell.org/package/text-2.0.2/docs/src/Data.Text.Lazy.html#breakOn - it looks like the indices are byte offsets. @stew maybe implement in terms of Text.breakOn, it's the size of the first element of the pair. |
|
I like
|
Yeah, if we can get |
@runarorama fyi, don't know if you saw, but the bug has been fixed, so you can add / replace the existing functions. |
Now there's a different bug:
⬇️
I can do a pure Unison check for the empty search string, but it really feels like the builtin should be doing this. The correct index of the empty string is |
Fixed in unisonweb/unison#4101 Replaced the Unison definitions with the builtins and pushed to main. |
There's now much more efficient implementations of these as builtins (see this PR)
I notice
Text.indexOf
exists but has a slow implementation. So maybe as simple as...Plus docs / tests. @runarorama if you want to assign this to @stew go ahead.
The text was updated successfully, but these errors were encountered: