-
-
Notifications
You must be signed in to change notification settings - Fork 312
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
Builtins to implement #664
Comments
Are any of these functions worth including in I've been maintaining
|
|
I've got a PR out for Str.trim. I could add trimLeft and trimRight after that, or leave those as nice intro issues. It would be nice to implement trim in terms of trimLeft and trimRight, or all three of those and dropPrefix/dropSuffix in terms of compiler-private Roc functions. |
@Giesch if you want to go for |
Is it necessary to include I'd say make them part of the standard library written in Roc, not written in Zig. There are way too many builtin symbols IMO. For example, all we need for
The rest can be written in Roc. |
I think we should define clearly what should go in where of:
Let's say I want to write commerce software that deal with currency. I want to make Float backed by DEC64 for no loss in precision in decimal. How do I swap out the implementation of Float and expect all other functions to work? |
Even if that weren't the case,
The Roc standard library refers to the builtins. The reason I chose the term builtins is to emphasize the fact that in Roc, the implementation of the standard library is built into the compiler. 😄 (It needs to be so that we can add extra metadata that gets used behind the scenes in compiler performance optimizations. That metadata should not be exposed outside the compiler!)
The priority with builtin types is for them to have nice Roc APIs and to run as fast as possible under the hood. I'm fine with however many symbols that ends up requiring!
We have a builtin See #1494 (comment) for the most recent developments. |
For the |
@matthiasbeyer Thanks for your comment. I've marked |
Should the request for |
In this case I think we'd rather have one Unlike some of the other scenarios we've talked about, I don't think there's anything particularly error-prone about the more flexible |
What would be the type of Should the annotation instead be (Should I move this |
Sorry, my mistake - for some reason I was thinking of My excuse is that it's past midnight here. 😆 Anyway, I think you're right - we should open a separate issue for this, and also that we should probably have individual functions - one for each numeric type - to convert a string to that numeric type. |
@rtfeldman Mind if I delete all completed tasks in the top comment? I don't know GH best practices for long task lists, but since more than half of the tasks are completed, it seems helpful to trim it down for clarity. (Perhaps I'd leave one completed task like |
@JanCVanB Yeah, go for it! 👍 |
40+ down, 40+ to go! Thank you, everyone who implemented this first batch of new builtins 😃
|
Marking this as high prio given the increasing number of folks interested in using Roc joining. |
@rtfeldman It would be great if this list could be updated, since a lot of them have been implemented since June |
@snprajwal updated! |
|
@Lunarmagpie updated! |
@rtfeldman I propose we close this issue. We can track the |
Awesome, sounds good! 🎉 |
Builtins to implement
These are some builtins we haven't yet implemented. When implementing a builtin, please:
List.dropAt
) in the title of the PR. This allows other contributors to find your PR later and use it as an example when they are trying to implement their first builtins.Num
maxU128 : U128
toI8 : Int * -> I8
toI16 : Int * -> I16
toI32 : Int * -> I32
toI64 : Int * -> I64
toI128 : Int * -> I128
toU8 : Int * -> U8
toU16 : Int * -> U16
toU32 : Int * -> U32
toU64 : Int * -> U64
toU128 : Int * -> U128
toF32 : Num * -> F32
toF64 : Num * -> F64
parseI16 : List U8, Endi, Nat -> Result I16 [ NotEnoughBytes ]*
parseU16 : List U8, Endi, Nat -> Result U16 [ NotEnoughBytes ]*
parseI32 : List U8, Endi, Nat -> Result I32 [ NotEnoughBytes ]*
parseU32 : List U8, Endi, Nat -> Result U32 [ NotEnoughBytes ]*
parseI64 : List U8, Endi, Nat -> Result I64 [ NotEnoughBytes ]*
parseU64 : List U8, Endi, Nat -> Result U64 [ NotEnoughBytes ]*
parseI128 : List U8, Endi, Nat -> Result I128 [ NotEnoughBytes ]*
parseU128 : List U8, Endi, Nat -> Result U128 [ NotEnoughBytes ]*
parseF32 : List U8, Endi, Nat -> Result F32 [ NotEnoughBytes ]*
parseF64 : List U8, Endi, Nat -> Result F64 [ NotEnoughBytes ]*
parseNat : List U8, Endi, Nat -> Result Nat [ NotEnoughBytes ]*
parseDec : List U8, Endi, Nat -> Result Dec [ NotEnoughBytes ]*
List
intersperse : List elem, elem -> List elem
#2001dropFirst : List elem -> List elem
#1896oks : List (Result elem *) -> List elem
#2504walkBackwardsUntil : List elem, state, (state, elem -> [ Continue state, Stop state ]) -> state
walkFrom : List elem, Nat, state, (state, elem -> state) -> state
(starts walking at the givenNat
index) (builtin(list): add List.walkFrom, List.walkFromUntil #4346)walkFromUntil : List elem, Nat, state, (state, elem -> [ Continue state, Stop state ]) -> state
(builtin(list): add List.walkFrom, List.walkFromUntil #4346)sortAscBy : List elem, (elem -> Num *) -> List elem
#6988sortDescBy : List elem, (elem -> Num *) -> List elem
#6989Result
map2 : Result a err, Result b err, (a, b -> c) -> Result c err
#6991map3 : Result a err, Result b err, Result c err, (a, b, c -> d) -> Result d err
map4 : Result a err, Result b err, Result c err, Result d err, (a, b, c, d -> e) -> Result e err
map5 : Result a err, Result b err, Result c err, Result d err, Result e err, (a, b, c, d, e -> f) -> Result f err
map6 : Result a err, Result b err, Result c err, Result d err, Result e err, Result f err, (a, b, c, d, e, f -> g) -> Result g err
map7 : Result a err, Result b err, Result c err, Result d err, Result e err, Result f err, Result g err, (a, b, c, d, e, f, g -> h) -> Result h err
map8 : Result a err, Result b err, Result c err, Result d err, Result e err, Result f err, Result g err, Result h err, (a, b, c, d, e, f, g, h -> i) -> Result i err
mapBoth : Result ok1 err1, (ok1 -> ok2), (err1 -> err2) -> Result ok2 err2
#6992try : Result before err, (before -> Result after err) -> Result after err
onErr : Result ok before, (before -> Result ok after) -> Result ok after
isOk : Result * * -> Bool
#1954isErr : Result * * -> Bool
#1965Str
withCapacity : Nat -> Str
dropPrefix : Str, Str -> Result Str {}
dropSuffix : Str, Str -> Result Str {}
trimRight : Str -> Str
#1972The text was updated successfully, but these errors were encountered: