Skip to main content

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 bifunctor;
24pub mod category;
25pub mod cloneable_fn;
26pub mod compactable;
27pub mod defer;
28pub mod filterable;
29pub mod foldable;
30pub mod function;
31pub mod functor;
32pub mod lift;
33pub mod monad;
34pub mod monad_rec;
35pub mod monoid;
36pub mod par_foldable;
37pub mod pointed;
38pub mod pointer;
39pub mod ref_counted_pointer;
40pub mod ref_functor;
41pub mod runnable;
42pub mod semiapplicative;
43pub mod semigroup;
44pub mod semigroupoid;
45pub mod semimonad;
46pub mod send_cloneable_fn;
47pub mod send_defer;
48pub mod send_ref_counted_pointer;
49pub mod send_unsized_coercible;
50pub mod traversable;
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", {});