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 bifoldable::Bifoldable;
pub use bifunctor::Bifunctor;
pub use bitraversable::Bitraversable;
pub use category::Category;
pub use cloneable_fn::CloneableFn;
pub use compactable::Compactable;
pub use contravariant::Contravariant;
pub use deferrable::Deferrable;
pub use evaluable::Evaluable;
pub use filterable::Filterable;
pub use foldable::Foldable;
pub use foldable_with_index::FoldableWithIndex;
pub use function::Function;
pub use functor::Functor;
pub use functor_with_index::FunctorWithIndex;
pub use lift::Lift;
pub use monad::Monad;
pub use monad_rec::MonadRec;
pub use monoid::Monoid;
pub use optics::AffineTraversalOptic;
pub use optics::FoldOptic;
pub use optics::GetterOptic;
pub use optics::GrateOptic;
pub use optics::IndexedFoldOptic;
pub use optics::IndexedGetterOptic;
pub use optics::IndexedLensOptic;
pub use optics::IndexedOpticAdapter;
pub use optics::IndexedOpticAdapterDiscardsFocus;
pub use optics::IndexedSetterOptic;
pub use optics::IndexedTraversalOptic;
pub use optics::IsoOptic;
pub use optics::LensOptic;
pub use optics::Optic;
pub use optics::PrismOptic;
pub use optics::ReviewOptic;
pub use optics::SetterOptic;
pub use optics::TraversalOptic;
pub use par_foldable::ParFoldable;
pub use pointed::Pointed;
pub use pointer::Pointer;
pub use profunctor::Profunctor;
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 traversable_with_index::TraversableWithIndex;
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.
bifoldable
Data structures with two type arguments that can be folded into a single value.
bifunctor
Types that can be mapped over two type arguments simultaneously.
bitraversable
Data structures with two type arguments that can be traversed in an applicative context.
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.
contravariant
Types that can be mapped over contravariantly.
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.
foldable_with_index
A Foldable with an additional index.
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.
functor_with_index
A Functor with an additional index.
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.
optics
Traits for optics.
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.
profunctor
Profunctors, which are functors contravariant in the first argument and covariant in the second.
ref_counted_pointer
Reference-counted pointers with shared ownership, unwrapping, and take-cell 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.
traversable_with_index
A Traversable with an additional index.
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.