-
Notifications
You must be signed in to change notification settings - Fork 30
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
fill out the Option module? #85
Comments
I surveyed F#, Rust, Belt, fp-ts, and OCaml. I also looked at the Javascript Array functions because an Option is sometimes like an array with either zero or one item in it. Here is what I found. https://1drv.ms/x/s!AjaZ-t3uLVN_0PAoyJH_Lj_zZBmu9w I think this encompasses the universe of potential functions we'd want to add to the Option module. Certainly don't want to add them all. I didn't understand a lot of the |
Here are some thoughts on a complete package and some usage examples. A few notes:
Maybe we should collaborate on the doc I posted? I can make it editable. Let me know how to proceed or general thoughts.
|
Great research! I think this could be very useful, but it's a bit hard to work with in its current form. Would it be possible to make it into a matrix, with the different functions listed in one dimension, and languages in the other? Something like this:
|
Ok I'll do that. I'll try a standardized name for each and make a pivot table. Hadn’t looked at rust before. Very cool! Interesting and weird ideas there for option like transpose and xor and Boolean and. Fp-ts has a very interesting one fromTryCatch where you give it a function and it wraps it in try catch and puts the value in Some if it succeeds and None if it throws.
…________________________________
From: Glenn Slotte ***@***.***>
Sent: Wednesday, March 8, 2023 7:28:01 AM
To: rescript-association/rescript-core ***@***.***>
Cc: jmagaram ***@***.***>; Author ***@***.***>
Subject: Re: [rescript-association/rescript-core] fill out the Option module? (Issue #85)
Great research! I think this could be very useful, but it's a bit hard to work with in its current form. Would it be possible to make it into a matrix, with the different functions listed in one dimension, and languages in the other. Something like this:
rescript-core JavaScript OCaml F# Rust
flat flat - flatten flattten
flatMap - bind bind and_then
forEach forEach iter iter iter
—
Reply to this email directly, view it on GitHub<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgh.neting.cc%2Frescript-association%2Frescript-core%2Fissues%2F85%23issuecomment-1460333272&data=05%7C01%7C%7C963f6b7713e94756b07d08db1fe9b4b1%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638138860835289195%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=KJT%2FEn0UCIyWmDAIgkIo3FmBQBhE6QUbtabvZ3Ej2Y4%3D&reserved=0>, or unsubscribe<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgh.neting.cc%2Fnotifications%2Funsubscribe-auth%2FADLZYS5NZF5RF7WVBQ6VGMDW3CQQDANCNFSM6AAAAAAVPF2ZGU&data=05%7C01%7C%7C963f6b7713e94756b07d08db1fe9b4b1%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638138860835289195%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=z%2FvhmCBIkl39KR7hUJi45HMHVNoXZ%2FerupLTmJHURVs%3D&reserved=0>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
I updated the spreadsheet if you want to play around with it. But here is the data. It's not totally accurate - I got lost in some of the fp-ts type classes and Rust has traits and there is the undefined/null confusion, but this is pretty close. I think next step is to collaboratively work on a
|
We could do a VS Code Live Share. Haven't played with it much and get on our phones to talk. Or a Design doc folder in the repo where we can put things like my spreadsheet, proposals, etc. I have an idea what a good |
Thank you for mapping that out. I'll keep this open for now, but please note that we're not looking to expand the surface of Core right now unless it's clear that it's for fixing bugs, or inconsistencies between things already in Core. |
Here is my completed proposal. When the time comes to expand the API surface, let me know and I'm happy to write some code and tests and docs for any/all of these. I will need your feedback. At the moment the API surface for option is very incomplete/weak and doesn't satisfy the goal "rich enough (without being bloated) so that you don't need to reach for anything else for typical ReScript development." I've had to write my own "OptionUtil" to fill the gaps. We could prioritize a bunch of this. For example, low priority would be all the
|
I like using Option. I'm wondering if the module should be filled out with some functions that are available in Option packages from other languages. Most of these functions are simple conveniences that aren't strictly necessary. But they lead to shorter and sometimes easier-to-understand code. If we provide conversion functions from both sides, like option->null and null->option, the programmer finds it more easily. Maybe standardize on terminology for lazy forms. These usually take just a few lines to implement. What do you think? Should we consider augmenting the Option module? Similar changes could be made to Result as well. I've looked at F# and fp-ts. Here are some ideas. If there is interest in this, I can do more research and make a proposal.
The text was updated successfully, but these errors were encountered: