public void CurryFunctionWithArity2() { const int a = 1; const uint b = 2u; var cf = Fn.Curry(FuncWithArity2); var actual1 = FuncWithArity2(a, b); var actual2 = cf(a)(b); Assert.That(actual1, Is.EqualTo(actual2)); }
public void CurryFunctionWithArity3() { const int a = 1; const uint b = 2u; const long c = 3L; var cf = Fn.Curry(FuncWithArity3); var actual1 = FuncWithArity3(a, b, c); var actual2 = cf(a)(b)(c); Assert.That(actual1, Is.EqualTo(actual2)); }
public void CurryFunctionWithArity5() { const int a = 1; const uint b = 2u; const long c = 3L; const float d = 4f; const double e = 5d; var cf = Fn.Curry(FuncWithArity5); var actual1 = FuncWithArity5(a, b, c, d, e); var actual2 = cf(a)(b)(c)(d)(e); Assert.That(actual1, Is.EqualTo(actual2)); }
public void MaybeApplicativeApplyOfCurriedFuncWithArity2() { const int a = 1; const uint b = 2u; var fa = a.Just(); var fb = b.Just(); var fn = Fn.Curry(FuncWithArity2); var actual = fn.Pure().Apply(fa).Apply(fb); Assert.That(actual.IsJust, Is.True); Assert.That(actual.FromJust, Is.EqualTo(Convert.ToString(a + b))); }
public void MaybeApplicativeApplyOfCurriedFuncWithArity3OfPartiallyAppliedFuncWithArity5() { const int a = 1; const uint b = 2u; const long c = 3L; const float d = 4f; const double e = 5d; var fc = c.Just(); var fd = d.Just(); var fe = e.Just(); var fn = Fn.Curry(Fn.PartiallyApply(FuncWithArity5, a, b)); var actual = fn.Pure().Apply(fc).Apply(fd).Apply(fe); Assert.That(actual.IsJust, Is.True); Assert.That(actual.FromJust, Is.EqualTo(Convert.ToString(a + b + c + d + e))); }
private static Maybe <MovieReview> ApReview(AssociationList alist) { return(Maybe.LiftM(Fn.Curry(MovieReview.MakeMovieReviewFunc), Lookup1("title", alist)) .Ap(Lookup1("user", alist)) .Ap(Lookup1("review", alist))); }
private static Either <string, MovieReview> LiftedReview(AssociationList alist) { return(Either.LiftM(Fn.Curry(MovieReview.MakeMovieReviewFunc), Lookup1("title", alist)) .Ap(Lookup1("user", alist)) .Ap(Lookup1("review", alist))); }