/// <summary> /// Functor `map` operation /// </summary> public static Cont <r, b> Map <r, a, b>(this Cont <r, a> that, Func <a, b> f) => Cont <r, b> .Create(k => that.Case(aˈ => k(f(aˈ))));
/// <summary> /// Put a function into a continuation, effectively running it /// </summary> public static r Run <r, a>(Func <a, r> f, Cont <r, a> cont) => cont.Case(f);
/// <summary> /// Execute continuation when argument type and return types are same /// </summary> public static r Uncont <r>(this Cont <r, r> that) => that.Case(Id);
/// <summary> /// Applicative functor lift /// </summary> public static Cont <r, c> Lift <r, a, b, c>(this Func <a, b, c> f, Cont <r, a> aˈ, Cont <r, b> bˈ) => Cont <r, c> .Create(k => aˈ.Case(aa => bˈ.Case(bb => k(f(aa, bb)))));
/// <summary> /// Applies a function inside an applicative context (see Applicative functors) /// </summary> public static Cont <r, b> Ap <r, a, b>(this Cont <r, Func <a, b> > f, Cont <r, a> aˈ) => Cont <r, b> .Create(k => aˈ.Case(aa => f.Case(ff => k(ff(aa)))));
/// <summary> /// Monad `join` operation /// </summary> public static Cont <r, a> Flatten <r, a>(this Cont <r, Cont <r, a> > that) => Cont <r, a> .Create(k => that.Case(aˈ => aˈ.Case(k)));