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`], [`Applicative`] and [`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 cloneable_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 pointer;
38pub mod ref_counted_pointer;
39pub mod semiapplicative;
40pub mod semigroup;
41pub mod semigroupoid;
42pub mod semimonad;
43pub mod send_cloneable_fn;
44pub mod send_defer;
45pub mod send_ref_counted_pointer;
46pub mod send_unsized_coercible;
47pub mod thunk_wrapper;
48pub mod traversable;
49pub mod try_monoid;
50pub mod try_semigroup;
51pub mod unsized_coercible;
52pub mod witherable;
53
54// Automatically re-export all traits defined in submodules.
55fp_macros::generate_trait_re_exports!("src/classes", {});