8000 Adding the rest of string sdk by michelchan · Pull Request #494 · finos/morphir-scala · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Adding the rest of string sdk #494

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

Merged
merged 40 commits into from
Dec 27, 2023
Merged

Adding the rest of string sdk #494

merged 40 commits into from
Dec 27, 2023

Conversation

michelchan
Copy link
Contributor
@michelchan michelchan commented Dec 21, 2023

Adding the following functions:

String    append
String    concat
String    contains
String    dropLeft
String    dropRight
String    endsWith
String    join
String    length
String    padLeft
String    padRight
String    right
String    slice
String    split
String    startsWith
String    toFloat
String    toLower
String    toUpper
String    trim
String    trimLeft
String    trimRight

Copy link
netlify bot commented Dec 21, 2023

Deploy Preview for scala-morphir failed.

Name Link
🔨 Latest commit 4f936bc
🔍 Latest deploy log https://app.netlify.com/sites/scala-morphir/deploys/6584a79ae8746d00090d264c

Copy link
Contributor
@justin-corn justin-corn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@justin-corn
Copy link
Contributor

lgtm

Wait, I forgot to review test cases. Consider that a tentative lgtm while I go back with a magnifying glass, please :)

@@ -1875,42 +1881,49 @@ basicsAlwaysTest x =
in
f [ 4 ]


{-| Test: SdkBasics/basicsClampTest
-}
basicsClampTest : a -> a -> a -> a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd change all of these type variables from a to number... IDK if it's the intention that that be a rigidly enforced in morphir, but it is in elm, and enforced or not is the only way of indicating that the type must belong to the number typeclass.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can do this in a separate pr since this was just part of running the formatter

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formatter changed number to a?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait, nvm I see what you meant, sure

{-| Test: SdkBasics/basicsIdentityTest
-}
basicsIdentityTest : a -> a
basicsIdentityTest x =
x


{-| Test: SdkBasics/basicsPowerTest
-}
basicsPowerTest : a -> a -> a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above regarding number

@justin-corn
Copy link
Contributor

I think finding a "split" in java/scala that takes a string rather than regex (so we can't throw) is importnat.

After that's fixed, lgtm.


val slice = DynamicNativeFunction3("slice") {
(context: NativeContext) => (start: RT.Primitive.Int, end: RT.Primitive.Int, str: RTString) =>
val result = str.value.slice(start.valueAsInt, end.valueAsInt)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, one last difference. Elm allows negative indexing in its slice [0], and java does not.

This seems like a difference that we can live with to me (meaning, leave this impl as-is), and would fit with the java/scala morphir backend tending to use default java behaviors instead of matching elm. @DamianReeves , any opinion?

[0] https://package.elm-lang.org/packages/elm/core/latest/String#slice

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with filing an issue (and JIRA) to track the need to align slice functionality... I do think it is desired to have this behavior match

Copy link
Contributor
@justin-corn justin-corn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the changes, lgtm

@michelchan michelchan merged commit 7a9ca19 into finos:main Dec 27, 2023
@michelchan michelchan deleted the stringsdk branch December 27, 2023 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0