/// <summary> /// Mirrors left and right /// </summary> public static Either <right, left> Flip <left, right>(this Either <left, right> that) => that.FlipHomo(that.Alg(), that.Alg().Flip());
/// <summary> /// Ensure that contained value (if any) satisfies the predicate or else return Left /// Enumerable.Where-like filter /// </summary> public static Either <left, right> Filter <left, right>(this Either <left, right> that, Func <right, bool> p, SNeutral <left, Unit> neutral = null) => // todo resolve neutral that.Map(p).GetRightOr(false) ? that : that.Alg().InjectLeft((neutral ?? AObject <left> .Class).NullOp());
/// <summary> /// Try to get right safely /// </summary> public static Opt <right> TryGetRight <left, right>(this Either <left, right> that) => that.BiMap(that.Alg(), _ => Unit(), Id, AOpt <right> .Class);