Пример #1
0
 public static IoEitherMaybe <TLeft, TRight> ToIoEitherMaybe <TLeft, TRight>(this IEither <TLeft, TRight> m)
 {
     return(new IoEitherMaybe <TLeft, TRight>(m.Select(r => r.ToMaybe())));
 }
Пример #2
0
 public EitherEnumerable <TLeft, TResult> FMap <TResult>(Func <TRight, TResult> f)
 {
     return(new EitherEnumerable <TLeft, TResult>(Out.Select(xs => xs.Select(f))));
 }
Пример #3
0
 public static IEither <L, R1> SelectMany <L, R, R1>(
     this IEither <L, R> source,
     Func <R, IEither <L, R1> > selector)
 {
     return(source.Select(selector).Join());
 }
Пример #4
0
 public static IEither <TResult, E> SelectMany <S, E, T, TResult>(this IEither <S, E> either, Func <S, IEither <T, E> > func, Func <S, T, TResult> select)
 {
     return(either.Select(x => func(x).Select(
                              y => select(x, y))));
 }
Пример #5
0
 public static IEither <TResult, E> Select <S, E, TResult>(this IEither <S, E> either, Func <S, TResult> func)
 {
     return(either.Select(x => Either.Success <TResult, E>(func(x))));
 }
Пример #6
0
 /// <summary>
 ///     Return an IEither(TLeft, TNewRight) instance by either passing the contained Right value
 ///     to a conversion function, or propagating the Left value.
 /// </summary>
 /// <typeparam name="TLeft">The type of a potential Left value.</typeparam>
 /// <typeparam name="TOldRight">The original type of a potential Right value.</typeparam>
 /// <typeparam name="TNewRight">The new type of a potential Right value.</typeparam>
 /// <param name="either">An IEither(TLeft, TOldRight) instance.</param>
 /// <param name="selector">Function used to convert a Right value.</param>
 public static IEither <TLeft, TNewRight> SelectRight <TLeft, TOldRight, TNewRight>(
     this IEither <TLeft, TOldRight> either, Func <TOldRight, TNewRight> selector)
 {
     return(either.Select(left => left, selector));
 }
Пример #7
0
 /// <summary>
 ///     Return an IEither(TNewLeft, TRight) instance by either passing the contained Left value
 ///     to a conversion function, or propagating the Right value.
 /// </summary>
 /// <typeparam name="TOldLeft">The original type of a potential Left value.</typeparam>
 /// <typeparam name="TNewLeft">The new type of a potential Left value.</typeparam>
 /// <typeparam name="TRight">The type of a potential Right value.</typeparam>
 /// <param name="either">An IEither(TOldLeft, TRight) instance.</param>
 /// <param name="selector">Function used to convert a Left value.</param>
 public static IEither <TNewLeft, TRight> SelectLeft <TOldLeft, TNewLeft, TRight>(
     this IEither <TOldLeft, TRight> either, Func <TOldLeft, TNewLeft> selector)
 {
     return(either.Select(selector, right => right));
 }