void_can_be_exressed_via_replace
This commit is contained in:
parent
ad5361cfbf
commit
f8d8a77b1f
@ -75,5 +75,8 @@ pub fn monad_follows_laws<'a, T: Monad<'a> + FunctorTestSuite<'a>>() -> R {
|
||||
T::sample(|pa| {
|
||||
res += fmap_can_be_expressed_via_bind::<T, _, _>(|x| x + 3, || pa(2));
|
||||
});
|
||||
T::sample(|pa| {
|
||||
res += void_can_be_exressed_via_replace::<T, _>(|| pa(2));
|
||||
});
|
||||
res
|
||||
}
|
||||
|
@ -317,3 +317,17 @@ pub fn fmap_can_be_expressed_via_bind<
|
||||
T::bind(fa0(), move |a| T::pure(f(a))),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn void_can_be_exressed_via_replace<
|
||||
'a,
|
||||
T: Monad<'a> + Eqr<'a>,
|
||||
A: 'a + Send + Debug + PartialEq,
|
||||
>(
|
||||
fa0: impl Fn() -> T::F<A>,
|
||||
) -> R {
|
||||
T::eqr(
|
||||
"void via bind: void x = () <$ x",
|
||||
T::void(fa0()),
|
||||
T::replace(fa0(), ()),
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user