Skip to main content

fp_library/
classes.rs

1//! Defines traits for common algebraic structures and functional abstractions,
2//! such as [`Functor`], [`Applicative`] and [`Monad`].
3//!
4//! Traits representing higher-kinded types (e.g., `Functor`) are implemented by
5//! [`Brand` types][crate::brands] to simulate higher-kinded polymorphism, as Rust does not
6//! natively support it.
7//!
8//! ### Examples
9//!
10//! ```
11//! use fp_library::{brands::*, functions::*};
12//!
13//! let x = Some(5);
14//! let y = map::<OptionBrand, _, _, _>(|i| i * 2, x);
15//! assert_eq!(y, Some(10));
16//! ```
17
18pub mod applicative;
19pub mod apply_first;
20pub mod apply_second;
21pub mod bifunctor;
22pub mod category;
23pub mod cloneable_fn;
24pub mod compactable;
25pub mod deferrable;
26pub mod evaluable;
27pub mod filterable;
28pub mod foldable;
29pub mod function;
30pub mod functor;
31pub mod lift;
32pub mod monad;
33pub mod monad_rec;
34pub mod monoid;
35pub mod par_foldable;
36pub mod pointed;
37pub mod pointer;
38pub mod ref_counted_pointer;
39pub mod ref_functor;
40pub mod semiapplicative;
41pub mod semigroup;
42pub mod semigroupoid;
43pub mod semimonad;
44pub mod send_cloneable_fn;
45pub mod send_deferrable;
46pub mod send_ref_counted_pointer;
47pub mod send_unsized_coercible;
48pub mod traversable;
49pub mod unsized_coercible;
50pub mod witherable;
51
52// Automatically re-export all traits defined in submodules.
53fp_macros::generate_trait_re_exports!("src/classes", {});