/// <summary> /// Bi-filter the Either /// </summary> /// <remarks> /// This may give unpredictable results for a filtered value. The Either won't /// return true for IsLeft or IsRight. IsBottom is True if the value is filtered and that /// should be checked for. /// </remarks> /// <typeparam name="L">Left</typeparam> /// <typeparam name="R">Right</typeparam> /// <param name="self">Either to filter</param> /// <param name="pred">Predicate function</param> /// <returns> /// If the Either is in the Left state then the Left predicate is run against it. /// If the Either is in the Right state then the Right predicate is run against it. /// If the predicate returns False the Either is returned in a 'Bottom' state.</returns> public static EitherUnsafe <L, R> filter <L, R>(EitherUnsafe <L, R> either, Func <R, bool> Right, Func <L, bool> Left) => either.Filter(Right, Left);
/// <summary> /// Filter the Either /// </summary> /// <remarks> /// This may give unpredictable results for a filtered value. The Either won't /// return true for IsLeft or IsRight. IsBottom is True if the value is filtered and that /// should be checked for. /// </remarks> /// <typeparam name="L">Left</typeparam> /// <typeparam name="R">Right</typeparam> /// <param name="self">Either to filter</param> /// <param name="pred">Predicate function</param> /// <returns>If the Either is in the Right state it is returned as-is. /// If in the Left state the predicate is applied to the Left value. /// If the predicate returns True the Either is returned as-is. /// If the predicate returns False the Either is returned in a 'Bottom' state.</returns> public static EitherUnsafe <L, R> filter <L, R>(EitherUnsafe <L, R> either, Func <L, bool> pred) => either.Filter(pred);