Skip to content

How to aggregate Errors efficiently like you can aggregate Validation #1070

Answered by louthy
kgkoutis asked this question in Q&A
Discussion options

You must be logged in to vote

Monadic operations force an order, and must exit as soon as there's an error. If you think about it it's obvious:

    from x in broken
    from y in working
    select x + y;

Clearly we can't have a situation where broken fails and then leaves x in an uninitialised state.

The way to achieve capture of multiple errors is to use applicatives, which are independent terms in an expression. Those independent terms can all be run and all errors collected, but it's a bit more awkward to do with C#.

I have just added support for a multi-error Error type, and applicative functor support to Aff and Eff.

It's a bit late here now, and I'll admit to having not fully read your request properly yet. How…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by kgkoutis
Comment options

You must be logged in to vote
0 replies
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