use crate::{Hom, Injective, RingHom, Surjective};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct Compose<F, G> {
pub f: F,
pub g: G,
}
impl<F, G> Compose<F, G> {
pub const fn new(f: F, g: G) -> Self {
Self { f, g }
}
}
impl<F, G> Hom for Compose<F, G>
where
F: Hom,
G: Hom<Domain = F::Codomain>,
{
type Domain = F::Domain;
type Codomain = G::Codomain;
fn apply(&self, x: Self::Domain) -> Self::Codomain {
self.g.apply(self.f.apply(x))
}
}
impl<F, G> RingHom for Compose<F, G>
where
F: RingHom,
G: RingHom<Domain = F::Codomain>,
{
}
impl<F, G> Injective for Compose<F, G>
where
F: Injective,
G: Injective<Domain = F::Codomain>,
{
}
impl<F, G> Surjective for Compose<F, G>
where
F: Surjective,
G: Surjective<Domain = F::Codomain>,
{
}