question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Suggestion: Add Bind and BindAsync function to the Result<>

See original GitHub issue

It would be nice to add to the library binding of Result<>

public Result<B> Bind<B>(Func<A, Result<B>> f)
public async Task<Result<B>> BindAsync<B>(Func<A, Task<Result<B>>> f)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
louthycommented, May 5, 2022

Fin<A> is a synchronous type, so it doesn’t make sense to have an BindAsync until there’s a FinAsync<A> pair (like EitherAsync for Either and OptionAsync for Option). Yes, it could return a Task<Fin<B>> but that then becomes a future breaking change when I add FinAsync.

You might want to consider using Eff and Aff - as they are effectively wrappers for functions that return Fin. I guess it depends on your use-case, but they are fully featured and are designed to play nice with each other. You can create success and fail values like so:

    var mx = SuccessEff(123);
    var my = FailEff(Error.New("error"));
    var mz = FailEff(new Exception());

They are lazy though, so you must call mx.Run() to get the Fin out of it. Outside of that, the other option would be to use Either<Error, A> and EitherAsync<Error, A>

1reaction
louthycommented, May 2, 2022

That’s true, I’d like to deprecate it at some point. The supported equivalent monad is: Fin<A>

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - How do I bind an async method that returns an Either ...
1 Answer. You're running into problems because not only is Either a monad, asynchronous computations (Tasks) are too. Thus, the Bind method you ......
Read more >
Bind Async · Issue #1404 · grpc/grpc-node
After i changed server.bind to bindAsync i am getting TypeError: callback must be a function As a result i passed a function as...
Read more >
SAP Fiori: How to bind async loaded model to UI?
How can I use a model that was loaded by an async AJAX request in the UI? What is the approach to load...
Read more >
Generating argument expressions for minimal APIs ...
In this post I look at some more expressions that RequestDelegateFactory.CreateArgument() generates to bind minimal API handler parameters.
Read more >
Triggers and bindings in Azure Functions
Add a binding by adding its specific definitions to your function. To learn how, see Add bindings to an existing function in Azure...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found