mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2025-09-06 16:53:11 +02:00
17 lines
699 B
C#
17 lines
699 B
C#
namespace Phantom.Utils.Monads;
|
|
|
|
public sealed record Right<TLeft, TRight>(TRight Value) : Either<TLeft, TRight> {
|
|
public override TLeft RequireLeft => throw new InvalidOperationException("Either<" + typeof(TLeft).Name + ", " + typeof(TRight).Name + "> has a right value, but left value was requested.");
|
|
public override TRight RequireRight => Value;
|
|
|
|
public override Either<TNewLeft, TRight> MapLeft<TNewLeft>(Func<TLeft, TNewLeft> func) {
|
|
return new Right<TNewLeft, TRight>(Value);
|
|
}
|
|
|
|
public override Either<TLeft, TNewRight> MapRight<TNewRight>(Func<TRight, TNewRight> func) {
|
|
return new Right<TLeft, TNewRight>(func(Value));
|
|
}
|
|
}
|
|
|
|
public sealed record Right<TValue>(TValue Value);
|