Rename & repurpose result.then #1866
NthTensor
started this conversation in
Ideas & suggestions
Replies: 1 comment 3 replies
-
I agree, the word I'm unsure if we should add special support for pipes with use result <- promise.await(
first_function()
|> second_function
|> third_function
) use result <- result.try(
first_function()
|> second_function
|> third_function
) |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Now that
use
has been released andtry
is intended for deprecation/removal, I want to bring up a proposal I saw in discord a few days ago: I think we should consider renaminggleam/result.then
totry
and instead usethen
for the curried version.Currently we have to write:
which several people in the discord seem dissatisfied with.
then
comes before the function, but it meanstry
the function first and then only go on if it was successful. The general consensus seems to be thatthen
is nicer after functions, and not before. There is also no obvious & friendly way touse
a result from a pipeline, as you have to do one of the following:With these API changes, we would write
I think this is a little more readable, and probably going to be more friendly to new users. I'd love to hear what the rest of you think. More generally, I think there is no reason we need to stick to
then
for this sort of pattern. If we are going to have to manually re-implement it for every type anyway, we should choose names which more closely describe the particular uses of that type.Implementing this proposal would require removing
try
as a keyword rather than simply deprecating it. If we would like to go the deprecation route, we could probably name the un-curried functionattempt
or something. The other major downside is that this would break a lot of people's code in a way that is easy but maybe slightly annoying to fix. But depreciating try would have this effect anyway, so it would be reasonable to introduce this change at the same time as the deprecation.Beta Was this translation helpful? Give feedback.
All reactions