use super::number::*;
pub trait PeanoAdd<N: Num> {
type Output: Num;
}
pub trait PeanoSub<N: Num> {
type Output: Num;
}
pub trait PeanoMul<N: Num> {
type Output: Num;
}
impl<N: Num> PeanoMul<Zero> for N {
type Output = Zero;
}
impl<N, M> PeanoMul<Next<M>> for N
where
N: Num + PeanoMul<M> + PeanoAdd<<N as PeanoMul<M>>::Output>,
M: Num,
<N as PeanoMul<M>>::Output: Num,
{
type Output = <N as PeanoAdd<<N as PeanoMul<M>>::Output>>::Output;
}
impl<N: Num> PeanoAdd<Zero> for N {
type Output = N;
}
impl<N, M> PeanoAdd<Next<M>> for N
where
N: Num + PeanoAdd<M>,
M: Num,
{
type Output = Next<<N as PeanoAdd<M>>::Output>;
}
impl<N: Num> PeanoSub<Zero> for N {
type Output = N;
}
impl<N, M> PeanoSub<Next<M>> for Next<N>
where
N: Num + PeanoSub<M>,
M: Num,
{
type Output = <N as PeanoSub<M>>::Output;
}