I have a seq like this:
let data =
seq {
for i in source do
do some stuff...
yield result
}
But I would like to turn it into a Result object and, during the iteration I have some conditions that mean an error. For example:
let data =
seq {
for i in source do
do some stuff...
if a > b then .. let's abort everything and return error
yield result
} |> Ok
The calculations are quite expensive, so it'd prefer not to wrap the yield with Option / Result and sort it out later if I can abort early.
Or, if I do that, how could I iterate until it either completes, or returns an error?
How can this be done?