public static T Force <TException, T>(this IEither <TException, T> either)
     where TException : Exception
 {
     return(either.Case(
                exception => { throw exception; },
                value => value));
 }
 public static IEither <TException, T1> SelectMany <TException, T0, T1>(
     this IEither <TException, T0> either,
     Func <T0, IEither <TException, T1> > selector)
 {
     return(either.Case(
                exception => Either.Left <TException, T1>(exception),
                value => selector(value)));
 }
Example #3
0
 public static IEither <TException, T1> Select <TException, T0, T1>(
     this IEither <TException, T0> either,
     Func <T0, T1> selector)
 {
     return(either.Case(
                left: exception => Either.Left <TException, T1>(exception),
                right: value => Either.Right <TException, T1>(selector(value))));
 }
Example #4
0
 public static res Case <left, right, res>(this IEither <left, right> that, Func <left, res> Left, Func <right, res> Right) =>
 that.Case(Left, App, Right, App);
        public override int Predict(FeatureVector feature)
        {
            var features = Array.ConvertAll(feature.BandIntensities, s => (double)s / ushort.MaxValue);

            return(_tree.Case(l => l.Decide(features), r => r.Compute(features)));
        }
Example #6
0
 public static IMaybe <Tr> Create <Tl, Tr>(IEither <Tr, IMaybe <Tr> > value)
 => value.Case(
     right: (right) => right,
     left: (left) => left);