Skip to content

Using Either and Bind when the outputs of two separate functions feeds into the next function #1210

Answered by JonTheTurnip
JonTheTurnip asked this question in Q&A
Discussion options

You must be logged in to vote

I think I've just discovered that if I use the Linq query syntax for select many then you can achieve this very easily? Still curious to know how best to do this using Bind method chaining though.

e.g

var result =
    await (
        from a in GetInputs()
        from b in UserConfirm(a).ToAsync()
        from c in Validate(b).ToAsync()
        from d in GetSomething().ToAsync()
        from e in DoMapping(c, d).ToAsync()
        select e
    );

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@louthy
Comment options

@JonTheTurnip
Comment options

Answer selected by JonTheTurnip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants