Skip to main content

Module classes

Module classes 

Source
Expand description

Defines traits for common algebraic structures and functional abstractions, such as Functor, Applicative and Monad.

Traits representing higher-kinded types (e.g., Functor) are implemented by Brand types to simulate higher-kinded polymorphism, as Rust does not natively support it.

§Examples

use fp_library::{brands::*, functions::*};

let x = Some(5);
let y = map::<OptionBrand, _, _, _>(|i| i * 2, x);
assert_eq!(y, Some(10));

Re-exports§

pub use applicative::Applicative;
pub use apply_first::ApplyFirst;
pub use apply_second::ApplySecond;
pub use bifunctor::Bifunctor;
pub use category::Category;
pub use cloneable_fn::CloneableFn;
pub use compactable::Compactable;
pub use deferrable::Deferrable;
pub use evaluable::Evaluable;
pub use filterable::Filterable;
pub use foldable::Foldable;
pub use function::Function;
pub use functor::Functor;
pub use lift::Lift;
pub use monad::Monad;
pub use monad_rec::MonadRec;
pub use monoid::Monoid;
pub use par_foldable::ParFoldable;
pub use pointed::Pointed;
pub use pointer::Pointer;
pub use ref_counted_pointer::RefCountedPointer;
pub use ref_functor::RefFunctor;
pub use semiapplicative::Semiapplicative;
pub use semigroup::Semigroup;
pub use semigroupoid::Semigroupoid;
pub use semimonad::Semimonad;
pub use send_cloneable_fn::SendCloneableFn;
pub use send_deferrable::SendDeferrable;
pub use send_ref_counted_pointer::SendRefCountedPointer;
pub use send_unsized_coercible::SendUnsizedCoercible;
pub use traversable::Traversable;
pub use unsized_coercible::UnsizedCoercible;
pub use witherable::Witherable;

Modules§

applicative
Applicative functors, allowing for values and functions to be wrapped and applied within a context.
apply_first
Sequencing of two computations while keeping the result of the first.
apply_second
Sequencing of two computations while keeping the result of the second.
bifunctor
Types that can be mapped over two type arguments simultaneously.
category
Categories, which are semigroupoids with an identity element for each object.
cloneable_fn
Cloneable wrappers over closures for generic handling of functions in higher-kinded contexts.
compactable
Data structures that can be compacted by filtering out None or separated by splitting Result values.
deferrable
Types that can be constructed lazily from a computation.
evaluable
Functors whose effects can be evaluated to produce an inner value.
filterable
Data structures that can be filtered and partitioned based on predicates or mapping functions.
foldable
Data structures that can be folded into a single value from the left or right.
function
Wrappers over closures for generic handling of functions in higher-kinded contexts.
functor
Types that can be mapped over, allowing functions to be applied to values within a context.
lift
Lifting of binary functions to operate on values within a context.
monad
Monads, allowing for sequencing computations where the structure depends on previous results.
monad_rec
Monads that support stack-safe tail recursion via the Step type.
monoid
Types that have an identity element and an associative binary operation.
par_foldable
Data structures that can be folded in parallel using thread-safe functions.
pointed
Contexts that can be initialized with a value via the pure operation.
pointer
Hierarchy of traits for abstracting over different types of pointers and their capabilities.
ref_counted_pointer
Reference-counted pointers with shared ownership and unwrapping capabilities.
ref_functor
Types that can be mapped over by receiving or returning references to their contents.
semiapplicative
Applying functions within a context to values within a context, without an identity element.
semigroup
Types that support an associative binary operation.
semigroupoid
Semigroupoids, representing objects and composable relationships (morphisms) between them.
semimonad
Sequencing of computations where the structure depends on previous results, without an identity element.
send_cloneable_fn
Thread-safe cloneable wrappers over closures that carry Send + Sync bounds.
send_deferrable
Deferred lazy evaluation using thread-safe thunks.
send_ref_counted_pointer
Thread-safe reference-counted pointers that carry Send + Sync bounds.
send_unsized_coercible
Pointer brands that can perform unsized coercion to thread-safe dyn Fn trait objects.
traversable
Data structures that can be traversed, accumulating results in an applicative context.
unsized_coercible
Pointer brands that can perform unsized coercion to dyn Fn trait objects.
witherable
Data structures that can be traversed and filtered simultaneously in an applicative context.