This project has moved. For the latest updates, please go here.

Select Either<TLeft,TValue>

Coordinator
May 4, 2011 at 8:05 AM

We have special select methods for IObservable<Either<TLeft,TValue>>.

Select<TLeft, TRight, TLeftResult, TRightResult>(this IObservable<Either<TLeft, TRight>>, source, Func<TLeft, TLeftResult> leftSelector, Func<TRight, TRightResult> rightSelector)

One problem is that this signature is not compatible with Query Comprehension Syntax. In addition (or instead?) should we have similar extensions for Either<TLeft,TValue>.

Either<TLeftResult, TRightResult> Select<TLeft, TRight, TLeftResult, TRightResult>(this Either<TLeft, TRight>, source, Func<TLeft, TLeftResult> leftSelector, Func<TRight, TRightResult> rightSelector)

This would allow you to write;

from either in xs
select either.Select(left => , right =>)

You could also have where either,

from either in xs
where either.Where(left => , right =>)
select either

Coordinator
May 4, 2011 at 9:07 AM

Where wouldn't be required, it's easy to just go;

where either.IsLeft ? (condition) : (condition)

Coordinator
May 4, 2011 at 7:51 PM

Hmm, I don't see the advantage.  Right now the query can be written more succinctly with our existing Select extension:

var query = xs.Select(left => , right =>)
Coordinator
May 4, 2011 at 7:52 PM

Or the expanded form:

from either in xs.Select(left => , right =>)
select either;