Files
SjkScripts/Functional/IEither.cs

15 lines
569 B
C#
Raw Normal View History

2026-04-04 13:18:04 -04:00
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();
}