From 30497ac69ced3df8ef012ecc94f902f82a8955df Mon Sep 17 00:00:00 2001 From: timofey Date: Sun, 15 Oct 2023 14:33:49 +0000 Subject: [PATCH] tuple_can_be_expressed_via_la2 --- src/func/test_suite.rs | 5 +++++ src/func/tests.rs | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/func/test_suite.rs b/src/func/test_suite.rs index ca2ed24..e1a53eb 100644 --- a/src/func/test_suite.rs +++ b/src/func/test_suite.rs @@ -52,6 +52,11 @@ pub fn applicative_follows_laws<'a, T: Applicative<'a> + FunctorTestSuite<'a>>() res += discard_can_be_expressed_via_seq_or_la2::(|| pa(2), || pb(2)); }) }); + T::sample(|pa| { + T::sample(|pb| { + res += tuple_can_be_expressed_via_la2::(|| pa(2), || pb(2)); + }) + }); res } diff --git a/src/func/tests.rs b/src/func/tests.rs index 0ce3d81..031d179 100644 --- a/src/func/tests.rs +++ b/src/func/tests.rs @@ -331,3 +331,19 @@ pub fn void_can_be_exressed_via_replace< T::replace(fa0(), ()), ) } + +pub fn tuple_can_be_expressed_via_la2< + 'a, + T: Applicative<'a> + Eqr<'a>, + A: 'a + Send + Debug + PartialEq, + B: 'a + Send + Debug + PartialEq, +>( + fa0: impl Fn() -> T::F, + fb0: impl Fn() -> T::F, +) -> R { + T::eqr( + "tuple via la2", + T::tuple((fa0(), fb0())), + T::la2(fa0(), fb0(), |a, b| (a, b)), + ) +}