fp_library/typeclasses/
applicative.rs1use crate::typeclasses::{Apply, ApplyFirst, ApplySecond, Functor, Pure};
2
3pub trait Applicative: Functor + Pure + Apply + ApplyFirst + ApplySecond {}
4
5impl<T> Applicative for T where T: Functor + Pure + Apply + ApplyFirst + ApplySecond {}
9
10#[cfg(test)]
11mod tests {
12 use crate::{
13 brands::OptionBrand,
14 typeclasses::Applicative,
15 types::{ResultWithErrBrand, ResultWithOkBrand, SoloBrand, VecBrand},
16 };
17
18 fn assert_applicative<T: Applicative>() {}
20
21 #[test]
22 fn test_brands_implement_applicative() {
26 assert_applicative::<SoloBrand>();
27 assert_applicative::<OptionBrand>();
28 assert_applicative::<ResultWithErrBrand<()>>();
29 assert_applicative::<ResultWithOkBrand<()>>();
30 assert_applicative::<VecBrand>();
31 }
32}