Esempio n. 1
0
 /// <summary>NothingをEitherのLeftへ</summary>
 public static Either <L, R> NullToLeft <T, L, R>(
     this Optional <T> self,
     Func <T, R> functor,
     Func <L> nothing)
 => self.IfPresent(
     o => Either <L, R> .Right(functor(o)),
     () => Either <L, R> .Left(nothing()));
Esempio n. 2
0
 /// <summary></summary>
 public static Either <L, T> NullToLeft <T, L>(
     this Optional <T> self,
     Func <L> nothing)
 => self.IfPresent(
     o => Either <L, T> .Right(o),
     () => Either <L, T> .Left(nothing()));
Esempio n. 3
0
 /// <summary></summary>
 public static Either <L, R> Return <L, R>(R right)
 => Either <L, R> .Right(right);
Esempio n. 4
0
 /// <summary>LとRを交換</summary>
 public static Either <R, L> Swap <R, L>(this Either <L, R> self)
 => self.IfRight(
     r => Either <R, L> .Left(r),
     l => Either <R, L> .Right(l));
Esempio n. 5
0
 /// <summary></summary>
 public static Either <L, R> Return <L, R>(TypeMarker <L> _, R right)
 => Either <L, R> .Right(right);