fp_library/
classes.rs

1//! Functional programming type classes.
2//!
3//! This module defines traits for common algebraic structures and functional abstractions,
4//! such as [`Functor`][functor::Functor], [`Applicative`][applicative::Applicative] and [`Monad`][monad::Monad].
5//!
6//! Traits representing higher-kinded types (e.g., `Functor`) are implemented by
7//! [`Brand` types][crate::brands] to simulate higher-kinded polymorphism, as Rust does not
8//! natively support it.
9//!
10//! ### Examples
11//!
12//! ```
13//! use fp_library::{brands::*, functions::*};
14//!
15//! let x = Some(5);
16//! let y = map::<OptionBrand, _, _, _>(|i| i * 2, x);
17//! assert_eq!(y, Some(10));
18//! ```
19
20pub mod applicative;
21pub mod apply_first;
22pub mod apply_second;
23pub mod category;
24pub mod clonable_fn;
25pub mod compactable;
26pub mod defer;
27pub mod filterable;
28pub mod foldable;
29pub mod function;
30pub mod functor;
31pub mod lift;
32pub mod monad;
33pub mod monoid;
34pub mod once;
35pub mod par_foldable;
36pub mod pointed;
37pub mod semiapplicative;
38pub mod semigroup;
39pub mod semigroupoid;
40pub mod semimonad;
41pub mod send_clonable_fn;
42pub mod traversable;
43pub mod witherable;