This project has moved and is read-only. For the latest updates, please go here.

Select Either<TLeft,TValue>

May 4, 2011 at 9: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

May 4, 2011 at 10:07 AM

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

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

May 4, 2011 at 8: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 =>)
May 4, 2011 at 8:52 PM

Or the expanded form:

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