Proposing new syntax for zero-cost unwrapping options/results
I’m not a fan of let? syntax. Mixing text and symbols just looks complicated I propose using maybe instead. Then the examples would look like this /* returns: string =>...
View ArticleProposing new syntax for zero-cost unwrapping options/results
I really like this addition! Whatever you decide to name this is great Just a couple of thoughts. Using the ? I think makes it confusing from wherever you come. In Javascript is already used for...
View ArticleProposing new syntax for zero-cost unwrapping options/results
let? is the best option so far. Would it be possible to just have let or would that make parsing too complex? let* looks wrong in ReScript to me, and maybe feels waaay out there.
View ArticleProposing new syntax for zero-cost unwrapping options/results
Lots of good feedback and things to unwrap (no pun intended), thank you! YKW: I propose using maybe instead. We’d like to avoid to add more keywords unless we really have to. let? is good like that...
View ArticleProposing new syntax for zero-cost unwrapping options/results
Glad I shared my thoughts. I 100% understand a new keyword is a major tradeoff. maybe reads so nice to me for some reason. and in the same, but opposite vein let? really irks me. It stands out the...
View ArticleProposing new syntax for zero-cost unwrapping options/results
I think need to also unwrap the Ok(_) may be a little too much syntax and I would much prefer let? without it: let getUser = async (id) => { /* if fetchUser returns Error e, the function returns...
View ArticleProposing new syntax for zero-cost unwrapping options/results
We want to signify that it’s not a normal assignment. It’s an operation with two possibilities: Unwrapping on success or Return on error. To me the following options read better: Modifying the...
View ArticleProposing new syntax for zero-cost unwrapping options/results
My 2 cents, this will be super useful in keeping code readable and flat, and I think it is a great addition. let? is fine, easy to get used to it and straightforward once you know. Like @hellos3b...
View ArticleProposing new syntax for zero-cost unwrapping options/results
I’m not sure about removing the Ok part. what if we want to support other stuff in the future? would let? Error(e) = fn() make sense? what about let? MyVariant1(x, y) = fn()? are there scenarios where...
View ArticleProposing new syntax for zero-cost unwrapping options/results
I really like the explicitness of the syntax and as said @xfcw it also allows a potential generalization in the future.
View ArticleProposing new syntax for zero-cost unwrapping options/results
I don’t see how removing the explicit variant would impede use of this syntax with “custom” types in the future. Instead of having to specify which variant we unwrap in the let? you could have an...
View ArticleProposing new syntax for zero-cost unwrapping options/results
As we spoke a lot about this on the retreat and after on discord, I really love this proposal, and the proposed syntax as in this post. I have a lot of use cases with server components and API code...
View ArticleHow to write Gherkin steps with ReScript ? ideas needed (vitest-bdd)
Hi everyone ! In my ongoing quest to support Behavior Driven Development at my company, I created a plugin “vitest-bdd” and I would like to support ReScript as well but do not really know how to solve...
View ArticleProposing new syntax for zero-cost unwrapping options/results
If we are open to a keyword, then I propose the peculiar keyword unlet instead of maybe: unlet Ok(user) = await fetchUser(id) It would mean, unless the RHS expression returns/resolves to an Error, we...
View ArticleHow to write Gherkin steps with ReScript ? ideas needed (vitest-bdd)
hey, I’m not sure what’s your issue here, you could use @as and externals to bind to functions with starting with an uppercase and bind to multiple languages at the same time: type givenUtils = {...
View ArticleProposing new syntax for zero-cost unwrapping options/results
Without meaning to sound harsh or rude, unlet is possibly the worst keyword I’ve ever seen, unless its intention is to unbind a let-binding or something similar… confusing to no end. sorry dude, unlet...
View ArticleHow to write Gherkin steps with ReScript ? ideas needed (vitest-bdd)
Thanks @tsnobip for the reply. I did not know about the @as argument which solves part of the problem. The other issue is that the type and number of parameters to “When” (or other step functions) can...
View ArticleProposing new syntax for zero-cost unwrapping options/results
What about let getUser = async (id) => { lets Ok(user) = await fetchUser(id) lets Ok(decodedUser) = decodeUser(user) Console.log(`Got user ${decodedUser.name}!`) lets Ok() = await...
View ArticleProposing new syntax for zero-cost unwrapping options/results
I have doubts… On the first hand, I would definitely go without the ?. I agree with some other posts that the question mark removes readability. My argument is that question marks in all the spoken...
View ArticleProposing new syntax for zero-cost unwrapping options/results
Not using a question mark would remove a valid syntax I use in tests where I’m sure of the shape I expect. The let? syntax is not perfect, but I still prefer it over the other syntaxes that were...
View Article