Example #1
0
 /// <summary>
 /// Runs a getter on an input and returns the result.
 /// Also known as <em>view</em>.
 /// </summary>
 public static A Get <S, A>(this IGetter <S, A> lens, S input)
 => (A)lens.GetFunc <Const <object, A>, Const <object, S> >()(a => new Const <object, A>(a))(input).RealValue;
Example #2
0
 /// <summary>
 /// Composes two getters. The second getter drills further into the result of the first.
 /// </summary>
 /// <typeparam name="S">The type of the outer container.</typeparam>
 /// <typeparam name="A">The type of the outer result/inner container.</typeparam>
 /// <typeparam name="AInner">The type of the inner result.</typeparam>
 /// <param name="lens">The outer getter.</param>
 /// <param name="then">The inner getter.</param>
 public static IGetter <S, AInner> Then <S, A, AInner>(this IGetter <S, A> lens, IGetter <A, AInner> then)
 {
     return(new Getter <S, AInner>(t => lens.GetFunc(t).After(then.GetFunc(t))));
 }