1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
use crate::{
boolean::Boolean,
control::{IfElsePredicate, IfElsePredicateOutput},
functional::Functor,
};
use std::ops::{Add, Mul, Sub};
use typenum::{Add1, Gr, IsGreater, IsLess, Le, Prod, Sub1, Sum, B1};
pub struct SumComposeFunctor;
impl<Lhs, Rhs> Functor<(Lhs, Rhs)> for SumComposeFunctor
where
Lhs: Add<Rhs>,
{
type Output = Sum<Lhs, Rhs>;
}
pub struct ProdComposeFunctor;
impl<Lhs, Rhs> Functor<(Lhs, Rhs)> for ProdComposeFunctor
where
Lhs: Mul<Rhs>,
{
type Output = Prod<Lhs, Rhs>;
}
pub struct MinComposeFunctor;
impl<Lhs, Rhs> Functor<(Lhs, Rhs)> for MinComposeFunctor
where
Rhs: IsLess<Lhs> + IfElsePredicate<Le<Rhs, Lhs>, Lhs>,
Le<Rhs, Lhs>: Boolean,
{
type Output = IfElsePredicateOutput<Rhs, Le<Rhs, Lhs>, Lhs>;
}
pub struct MaxComposeFunctor;
impl<Lhs, Rhs> Functor<(Lhs, Rhs)> for MaxComposeFunctor
where
Rhs: IsGreater<Lhs> + IfElsePredicate<Gr<Rhs, Lhs>, Lhs>,
Gr<Rhs, Lhs>: Boolean,
{
type Output = IfElsePredicateOutput<Rhs, Gr<Rhs, Lhs>, Lhs>;
}
pub struct AddOneFunctor;
impl<Value> Functor<Value> for AddOneFunctor
where
Value: Add<B1>,
{
type Output = Add1<Value>;
}
pub struct SubOneFunctor;
impl<Value> Functor<Value> for SubOneFunctor
where
Value: Sub<B1>,
{
type Output = Sub1<Value>;
}