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
Noneor separated by splittingResultvalues. - 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
Steptype. - 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
pureoperation. - 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 + Syncbounds. - send_
deferrable - Deferred lazy evaluation using thread-safe thunks.
- send_
ref_ counted_ pointer - Thread-safe reference-counted pointers that carry
Send + Syncbounds. - send_
unsized_ coercible - Pointer brands that can perform unsized coercion to thread-safe
dyn Fntrait 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 Fntrait objects. - witherable
- Data structures that can be traversed and filtered simultaneously in an applicative context.