예제 #1
0
 /// <summary>
 /// Runs an <see cref="IWithering{S, T, A, B}"/> on <paramref name="input"/>.
 /// </summary>
 /// <typeparam name="S">The type of the input structure.</typeparam>
 /// <typeparam name="T">The type of the resultant structure.</typeparam>
 /// <typeparam name="A">The type of the part to get.</typeparam>
 /// <typeparam name="B">The type of the result of the inner function.</typeparam>
 /// <param name="alternative">The type of the alternative result of the inner function.</param>
 /// <param name="lens">The traversal to run.</param>
 /// <param name="f">The function to apply to each element.</param>
 /// <param name="input">The input.</param>
 public static IApplicative <T> TraverseMaybe <S, T, A, B>(
     this IWithering <S, T, A, B> lens,
     Type alternative,
     Func <A, IAlternative <B> > f,
     S input)
 => lens.WitherFunc(alternative)(x => f(x))(input);
예제 #2
0
 /// <summary>
 /// Composes two witherings. The second withering drills further into the result of the first.
 /// </summary>
 /// <typeparam name="S">The type of the outer container.</typeparam>
 /// <typeparam name="T">The type of the resulting outer container.</typeparam>
 /// <typeparam name="A">The type of the outer value.</typeparam>
 /// <typeparam name="AInner">The type of the inner outer value/inner container.</typeparam>
 /// <typeparam name="B">The type outer result value.</typeparam>
 /// <typeparam name="BInner">The type of the inner result value.</typeparam>
 /// <param name="lens">The outer setter.</param>
 /// <param name="then">The inner setter.</param>
 public static IWithering <S, T, AInner, BInner> Then <S, T, A, B, AInner, BInner>(this IWithering <S, T, A, B> lens, IWithering <A, B, AInner, BInner> then)
 {
     return(new Withering <S, T, AInner, BInner>(t => lens.WitherFunc(t).After(then.WitherFunc(t))));
 }