FunSharp.Common/EitherExtensions.cs
//--------------------------------------------------
/// <summary>
/// If <paramref name="either" /> is left, use
/// it to compute another <see cref="Either{TLeft,TRight}"/>.
/// </summary>
If  is left, use
it to compute another .
If is left use it to compute another .
[NotNull]
        public static Either<TLeft2, TRight> BindLeft<TLeft1, TLeft2, TRight>(
            [NotNull] this Either<TLeft1, TRight> either,
            [NotNull] Func<TLeft1, Either<TLeft2, TRight>> makeNextChoice)
        {
            if (either is null) throw new ArgumentNullException(nameof(either));
            if (makeNextChoice is null) throw new ArgumentNullException(nameof(makeNextChoice));
            switch (either)
            {
                case EitherLeft<TLeft1, TRight> left: return makeNextChoice(left.Value);
                case EitherRight<TLeft1, TRight> right: return Either.Right(right.Value, new TypeHint<TLeft2>());
                default: throw new ArgumentOutOfRangeException(nameof(either));
            }
        }
[ NotNull ] public static Either < TLeft2 , TRight > BindLeft < TLeft1 , TLeft2 , TRight > ( [ NotNull ] this Either < TLeft1 , TRight > either , [ NotNull ] Func < TLeft1 , Either < TLeft2 , TRight > > makeNextChoice ) { if ( either is null ) throw new ArgumentNullException ( nameof ( either ) ) ; if ( makeNextChoice is null ) throw new ArgumentNullException ( nameof ( makeNextChoice ) ) ; switch ( either ) { case EitherLeft < TLeft1 , TRight > left : return makeNextChoice ( left . Value ) ; case EitherRight < TLeft1 , TRight > right : return Either . Right ( right . Value , new TypeHint < TLeft2 > ( ) ) ; default : throw new ArgumentOutOfRangeException ( nameof ( either ) ) ; } }
If  is left, use
it to compute another .
If is left use it to compute another .
this
[NotNull]
Func<TLeft1, Either<TLeft2, TRight>>
[NotNull]