-
Notifications
You must be signed in to change notification settings - Fork 471
add belt.String #2758
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 belt.String #2758
Conversation
Should we not choose lists over arrays when possible? e.g. String.split |
Could the API use named parameters? I always forget what is what when using values like this:
|
Hey could we get this merged? I'd love to have a split function finally lol |
@andreypopp that makes sense. |
The native side will need some love. I can start implementing them as soon as you merge but I wouldn't mind some help :) |
I've been writing many of these string helpers in pure Reason. Is there a desire to implement them as JS externals? If they were implemented in OCaml, wouldn't they be cross-platform? |
We can implement them as externals when compiling to JS and in Reason when compiling to native, that's probably the best of both worlds :) |
@bsansouci I haven't reviewed everything but a potential downside would be if the JS APIs aren't the best APIs. For example, I'm writing a lot of my string methods to return Option. |
null in JS is modeled as option in native, so you're good. To be honest, these are just string manipulation functions, there's only so far you can go with their API. We might have another version of |
@bsansouci I always felt like a goal of Belt was to remove the |
Oh well I think we'll be able to / already can compile options to unboxed nulls in JS, so there's no downsides I see to using them in both JS and native. I meant more that on the "backend" side of things, we have the power to do things slightly differently (in this very specific case of optionals), so we don't always need to re-write in Reason. |
I would love to see this released :) |
]} | ||
*) | ||
external replace : t -> t -> t -> t = "" [@@bs.send] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good place to use label?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can PR and target your branch if you want.
I'm planning on also adding Belt.String.length
, Belt.String.slice/sliceToEnd
, Belt.String.get
, Belt.String.indexOf
if that's ok with you.
should it also include Belt.String.replaceRegex
, Belt.String.matchRegex
ou should they just remain in Js.String
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the type of indexOf, I suggest we avoid char type in the API, otherwise it looks good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the type would be t -> t -> int option
closing very old PRs |
see #2759