Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

Proposing new syntax for zero-cost unwrapping options/results

$
0
0

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 can expect the value to be unwrapped and let-assigned to user variable. That also makes let and unlet keywords siblings. I hardly think anyone would use the unlet keyword for something else.

I agree with keeping OK() for the sake of clarity and keeping it unmagical.


Viewing all articles
Browse latest Browse all 2592

Trending Articles