Crate deep_causality_haft

Crate deep_causality_haft 

Source
Expand description

The deep_causality_haft crate provides foundational traits and utilities for implementing Higher-Kinded Types (HKTs) and functional programming patterns (Functor, Applicative, Monad, Foldable) in Rust.

This crate is a core component of the deep_causality project, enabling the construction of flexible and robust type-encoded effect systems.

§Core Concepts

  • Higher-Kinded Types (HKTs): Abstractions over type constructors (e.g., Option<T>, Vec<T>). This allows writing generic code that works across different container types.
  • Functor: Defines the fmap operation for mapping a function over a type constructor.
  • Applicative: Extends Functor with pure (to lift values) and apply (to apply functions within a context).
  • Monad: Provides the bind operation for sequencing computations that produce effectful values.
  • Foldable: Defines the fold operation for reducing a data structure to a single value.
  • Type-Encoded Effect Systems: A mechanism to explicitly track and manage side-effects (like errors, logging, counters) using Rust’s type system, ensuring compile-time verification.

§Modules

  • core: Core HKT definitions and machinery.
  • algebra: Algebraic traits (Functor, Monad, etc.).
  • effect_system: Type-encoded effect system traits.
  • extensions: Concrete HKT witness implementations for standard Rust types.
  • utils_tests: Internal utilities and test-specific effect types.

§Usage

This crate is primarily intended for internal use within the deep_causality project to build its core abstractions. However, the traits and concepts can be generally applied to other Rust projects requiring advanced functional programming patterns and effect management.

Modules§

utils_tests
This module provides utility types and implementations primarily used for testing and demonstrating the type-encoded effect system within deep_causality_haft.

Structs§

BTreeMapWitness
BTreeMapWitness<K> is a zero-sized type that acts as a Higher-Kinded Type (HKT) witness for the BTreeMap<K, V> type constructor, where the key type K is fixed.
BoxWitness
BoxWitness is a zero-sized type that acts as a Higher-Kinded Type (HKT) witness for the Box<T> type constructor. It allows Box to be used with generic functional programming traits like Functor, Applicative, Foldable, and Monad.
HashMapWitness
HashMapWitness<K> is a zero-sized type that acts as a Higher-Kinded Type (HKT) witness for the HashMap<K, V> type constructor, where the key type K is fixed.
LinkedListWitness
LinkedListWitness is a zero-sized type that acts as a Higher-Kinded Type (HKT) witness for the LinkedList<T> type constructor. It allows LinkedList to be used with generic functional programming traits like Functor, Applicative, Foldable, and Monad.
NoConstraint
The universal constraint — every type satisfies it.
OptionWitness
OptionWitness is a zero-sized type that acts as a Higher-Kinded Type (HKT) witness for the Option<T> type constructor. It allows Option to be used with generic functional programming traits like Functor, Applicative, Foldable, and Monad.
Placeholder
A zero-sized type used purely as a marker or placeholder when implementing Higher-Kinded Type (HKT) traits for concrete types.
ResultUnboundWitness
ResultUnboundWitness is a zero-sized type that acts as a witness for the Result<A, B> type constructor where both parameters are unbound.
ResultWitness
ResultWitness<E> is a zero-sized type that acts as a Higher-Kinded Type (HKT) witness for the Result<T, E> type constructor, where the error type E is fixed.
Tuple2Witness
Tuple2Witness acts as a witness for the (A, B) type constructor.
Tuple3Witness
Tuple3Witness acts as a witness for the (A, B, C) type constructor.
VecDequeWitness
VecDequeWitness is a zero-sized type that acts as a Higher-Kinded Type (HKT) witness for the VecDeque<T> type constructor. It allows VecDeque to be used with generic functional programming traits like Functor and Foldable.
VecWitness
VecWitness is a zero-sized type that acts as a Higher-Kinded Type (HKT) witness for the Vec<T> type constructor. It allows Vec to be used with generic functional programming traits like Functor, Applicative, Foldable, and Monad.

Traits§

Adjunction
The Adjunction trait defines a pair of adjoint functors L (Left) and R (Right) with an optional runtime Context.
AliasAdjunction
Alias trait for Adjunction providing more intuitive method names.
AliasCoMonad
Alias trait for CoMonad providing more intuitive method names.
AliasFoldable
Alias trait for Foldable providing more intuitive method names.
AliasFunctor
Alias trait for Functor providing more intuitive method names.
AliasMonad
Alias trait for Monad providing more intuitive method names.
AliasProfunctor
Alias trait for Profunctor providing more intuitive method names.
Applicative
The Applicative trait extends Functor and Pure by providing the apply operation to apply a function wrapped in a context to a value wrapped in a context.
Bifunctor
The Bifunctor trait allows mapping over both arguments of a type constructor F<A, B>.
CoMonad
The CoMonad trait represents a comonadic context, which is the dual of a Monad.
CyberneticLoop
The CyberneticLoop trait models a complete feedback control system involving 5 distinct components.
Effect3
Effect3: The Bridge Trait for Arity 3 Type Constructors.
Effect4
Effect4: The Bridge Trait for Arity 4 Type Constructors.
Effect5
Effect5: The Bridge Trait for Arity 5 Type Constructors.
Effect3Unbound
Effect3Unbound: Parametric Effect Trait for Arity 3.
Effect4Unbound
Effect4Unbound: Parametric Effect Trait for Arity 4.
Effect5Unbound
Effect5Unbound: Parametric Effect Trait for Arity 5.
Foldable
The Foldable trait abstracts over data structures that can be reduced to a single summary value.
Functor
The Functor trait abstracts over types that can be mapped over.
HKT
Trait for a Higher-Kinded Type (HKT) with one type parameter (arity 1).
HKT2
Trait for a Higher-Kinded Type (HKT) with two type parameters (arity 2).
HKT3
Trait for a Higher-Kinded Type (HKT) with three type parameters (arity 3).
HKT4
Trait for a Higher-Kinded Type (HKT) with four type parameters (arity 4).
HKT5
Trait for a Higher-Kinded Type (HKT) with five type parameters (arity 5).
HKT2Unbound
Trait for a Higher-Kinded Type (HKT) with two unbound generic parameters (Arity 2).
HKT3Unbound
Trait for a Higher-Kinded Type (HKT) with three generic parameters (Arity 3).
HKT4Unbound
Trait for a Higher-Kinded Type (HKT) with four generic parameters (Arity 4).
HKT5Unbound
Trait for a Higher-Kinded Type (HKT) with five generic parameters (Arity 5).
HKT6Unbound
Trait for a Higher-Kinded Type (HKT) with six generic parameters (Arity 6).
LogAddEntry
LogAppend
Trait for types that can append log entries from another instance of themselves.
LogEffect
LogSize
Monad
The Monad trait extends Functor and Pure by providing the bind operation for sequencing computations that produce effectful values.
MonadEffect3
Monadic logic for an Arity 3 type after it has been partially applied via Effect3.
MonadEffect4
Monadic logic for an Arity 4 type after it has been partially applied via Effect4.
MonadEffect5
Monadic logic for an Arity 5 type after it has been partially applied via Effect5.
MonadEffect3Unbound
Monadic logic for Parametric Effects (Arity 3 Unbound).
MonadEffect4Unbound
Monadic logic for Parametric Effects (Arity 4 Unbound).
MonadEffect5Unbound
Monadic logic for Parametric Effects (Arity 5 Unbound).
ParametricMonad
The ParametricMonad (or Indexed Monad) trait allows for monadic computations where the type of the underlying state can change at each step.
Profunctor
The Profunctor trait represents a type constructor that is contravariant in its first argument and covariant in its second argument.
Promonad
The Promonad trait models the “fusion” or “interaction” of two contexts to produce a third.
Pure
The Pure trait provides the ability to lift a value into a context.
RiemannMap
The RiemannMap trait models high-arity geometric interactions, specifically the Riemann Curvature Tensor and Scattering Matrices.
Satisfies
Marker trait indicating that type T satisfies constraint C.
Traversable
The Traversable trait abstracts over data structures that can be “traversed” or “sequenced” in a way that preserves effects. It combines the capabilities of Functor (mapping over elements) and Foldable (reducing to a single value).