From 9d0d9028a42207fdeb20d88b9e4d056e2b6cdf20 Mon Sep 17 00:00:00 2001 From: timofey Date: Tue, 25 Apr 2023 10:52:40 +0000 Subject: [PATCH] SharedFunctor for CompositionClass --- src/func/classes/composition.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/func/classes/composition.rs b/src/func/classes/composition.rs index 8ae9645..7a7c5ca 100644 --- a/src/func/classes/composition.rs +++ b/src/func/classes/composition.rs @@ -145,3 +145,23 @@ impl LocalFunctor for CompositionCla U::stuff::<_, T>(U::fmap(V::stuff::<_, T>, fa)) } } + +impl SharedFunctor for CompositionClass { + type Shared<'a, A: 'a + Clone> = U::Shared<'a, V::Shared<'a, A>> + where + Self: 'a; + + fn share<'a, A: 'a + Clone>(fa: Self::F<'a, A>) -> Self::Shared<'a, A> + where + Self: 'a, + { + U::share(U::fmap(V::share, fa)) + } + + fn unshare<'a, A: 'a + Clone>(sa: Self::Shared<'a, A>) -> Self::F<'a, A> + where + Self: 'a, + { + U::fmap(V::unshare, U::unshare(sa)) + } +}