示例#1
0
文件: Either.cs 项目: ArnasJ/tlplib
   public static Either <A, B> opt <A, B>(bool condition, Fn <A> ifFalse, Fn <B> ifTrue) =>
   condition
 ? Either <A, B> .Right(ifTrue())
 : Either <A, B> .Left(ifFalse());
示例#2
0
 [PublicAPI] public static Future <Either <A, BB> > flatMapT <B, BB, A>(
     this Future <Either <A, B> > m, Fn <B, Future <BB> > mapper
     ) => m.flatMap(_ => _.fold(
                        err => Future.successful(Either <A, BB> .Left(err)),
                        from => mapper(from).map(Either <A, BB> .Right)
                        ));
示例#3
0
文件: Either.cs 项目: ArnasJ/tlplib
   public static Either <A, B> opt <A, B>(bool condition, A ifFalse, B ifTrue) =>
   condition
 ? Either <A, B> .Right(ifTrue)
 : Either <A, B> .Left(ifFalse);
示例#4
0
        public void WhenLeftEquals()
        {
            Either <int, string> .Left(0).shouldEqual(Either <int, string> .Left(0));

            Either <int, string> .Left(10).shouldEqual(Either <int, string> .Left(10));
        }
示例#5
0
 [PublicAPI] public static Future <Either <A, BB> > flatMapT <A, B, BB>(
     this Future <Either <A, B> > m, Fn <B, Future <Either <A, BB> > > mapper
     ) => m.flatMap(_ => _.fold(
                        a => Future.successful(Either <A, BB> .Left(a)),
                        mapper
                        ));
示例#6
0
 [Test] public void WhenLeft() =>
 Either <int, string> .Left(3)
 .toTry(onLeft)
 .shouldBeError(typeof(ArgumentException));
示例#7
0
 [Test] public void WhenLeft() => Either <int, string> .Left(3).swap.shouldBeRight(3);
示例#8
0
 [Test] public void WhenLeft() => Either <int, string> .Left(3).fold(folder, folder).shouldEqual('3');
示例#9
0
 [Test] public void WhenLeft() => test(Either <int, string> .Left(3), '3');
示例#10
0
文件: Option.cs 项目: ArnasJ/tlplib
 public Either <A, B> toLeft <B>(Fn <B> right) =>
 isSome ? Either <A, B> .Left(__unsafeGetValue) : Either <A, B> .Right(right());
示例#11
0
文件: Option.cs 项目: ArnasJ/tlplib
 public Either <B, A> toRight <B>(Fn <B> left) =>
 isSome ? Either <B, A> .Right(__unsafeGetValue) : Either <B, A> .Left(left());
示例#12
0
 [PublicAPI] public Either <B, A> toRight <B>(B left) =>
 isSome ? Either <B, A> .Right(__unsafeGetValue) : Either <B, A> .Left(left);
示例#13
0
 [PublicAPI] public Either <A, B> toLeft <B>(B right) =>
 isSome ? Either <A, B> .Left(__unsafeGetValue) : Either <A, B> .Right(right);
示例#14
0
   public static Either <ImmutableList <A>, B> asValidationErrors <A, B>(
       this ImmutableList <A> errors, Fn <B> b
       ) =>
   errors.IsEmpty
 ? Either <ImmutableList <A>, B> .Right(b())
 : Either <ImmutableList <A>, B> .Left(errors);
示例#15
0
文件: Option.cs 项目: Hengle/Tetris-1
 public Either <B, A> toRight <B>(Fn <B> left)
 {
     return(isSome ? Either <B, A> .Right(value) : Either <B, A> .Left(left()));
 }
示例#16
0
文件: Option.cs 项目: Hengle/Tetris-1
 public Either <A, B> toLeft <B>(Fn <B> right)
 {
     return(isSome ? Either <A, B> .Left(value) : Either <A, B> .Right(right()));
 }