示例#1
0
 public static TryOption <EitherUnsafe <L, B> > Traverse <L, A, B>(this EitherUnsafe <L, TryOption <A> > ma, Func <A, B> f) => () =>
 {
     if (ma.IsBottom)
     {
         return(OptionalResult <EitherUnsafe <L, B> > .Bottom);
     }
     else if (ma.IsLeft)
     {
         return(new OptionalResult <EitherUnsafe <L, B> >(LeftUnsafe <L, B>(ma.LeftValue)));
     }
     else
     {
         var mr = ma.RightValue();
         if (mr.IsBottom)
         {
             return(new OptionalResult <EitherUnsafe <L, B> >(BottomException.Default));
         }
         if (mr.IsFaulted)
         {
             return(new OptionalResult <EitherUnsafe <L, B> >(mr.Exception));
         }
         if (mr.IsNone)
         {
             return(OptionalResult <EitherUnsafe <L, B> > .None);
         }
         return(new OptionalResult <EitherUnsafe <L, B> >(EitherUnsafe <L, B> .Right(f(mr.Value.Value))));
     }
 };