15 lines
569 B
C#
15 lines
569 B
C#
namespace SJK.Functional;
|
|
|
|
public interface IEither<TLeft, TRight>
|
|
{
|
|
IEither<TNewLeft, TRight> MapLeft<TNewLeft>(Func<TLeft, TNewLeft> mapping);
|
|
IEither<TLeft, TNewRight> MapRight<TNewRight>(Func<TRight, TNewRight> mapping);
|
|
TLeft Reduce(Func<TRight, TLeft> mapping);
|
|
(TLeft?, TRight?) Deconstruct();
|
|
TResult Match<TResult>(Func<TLeft, TResult> left, Func<TRight, TResult> right);
|
|
void Match(Action<TLeft> left, Action<TRight> right);
|
|
IEither<TLeft, T2> Bind<T2>(Func<TRight, IEither<TLeft, T2>> value);
|
|
bool IsRight();
|
|
bool IsLeft() => !IsRight();
|
|
}
|