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
fmapoperation for mapping a function over a type constructor. - Applicative: Extends
Functorwithpure(to lift values) andapply(to apply functions within a context). - Monad: Provides the
bindoperation for sequencing computations that produce effectful values. - Foldable: Defines the
foldoperation 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§
- BTree
MapWitness BTreeMapWitness<K>is a zero-sized type that acts as a Higher-Kinded Type (HKT) witness for theBTreeMap<K, V>type constructor, where the key typeKis fixed.- BoxWitness
BoxWitnessis a zero-sized type that acts as a Higher-Kinded Type (HKT) witness for theBox<T>type constructor. It allowsBoxto be used with generic functional programming traits likeFunctor,Applicative,Foldable, andMonad.- Hash
MapWitness HashMapWitness<K>is a zero-sized type that acts as a Higher-Kinded Type (HKT) witness for theHashMap<K, V>type constructor, where the key typeKis fixed.- Linked
List Witness LinkedListWitnessis a zero-sized type that acts as a Higher-Kinded Type (HKT) witness for theLinkedList<T>type constructor. It allowsLinkedListto be used with generic functional programming traits likeFunctor,Applicative,Foldable, andMonad.- NoConstraint
- The universal constraint — every type satisfies it.
- Option
Witness OptionWitnessis a zero-sized type that acts as a Higher-Kinded Type (HKT) witness for theOption<T>type constructor. It allowsOptionto be used with generic functional programming traits likeFunctor,Applicative,Foldable, andMonad.- Placeholder
- A zero-sized type used purely as a marker or placeholder when implementing Higher-Kinded Type (HKT) traits for concrete types.
- Result
Unbound Witness ResultUnboundWitnessis a zero-sized type that acts as a witness for theResult<A, B>type constructor where both parameters are unbound.- Result
Witness ResultWitness<E>is a zero-sized type that acts as a Higher-Kinded Type (HKT) witness for theResult<T, E>type constructor, where the error typeEis fixed.- Tuple2
Witness Tuple2Witnessacts as a witness for the(A, B)type constructor.- Tuple3
Witness Tuple3Witnessacts as a witness for the(A, B, C)type constructor.- VecDeque
Witness VecDequeWitnessis a zero-sized type that acts as a Higher-Kinded Type (HKT) witness for theVecDeque<T>type constructor. It allowsVecDequeto be used with generic functional programming traits likeFunctorandFoldable.- VecWitness
VecWitnessis a zero-sized type that acts as a Higher-Kinded Type (HKT) witness for theVec<T>type constructor. It allowsVecto be used with generic functional programming traits likeFunctor,Applicative,Foldable, andMonad.
Traits§
- Adjunction
- The
Adjunctiontrait defines a pair of adjoint functorsL(Left) andR(Right) with an optional runtimeContext. - Alias
Adjunction - Alias trait for
Adjunctionproviding more intuitive method names. - Alias
CoMonad - Alias trait for
CoMonadproviding more intuitive method names. - Alias
Foldable - Alias trait for
Foldableproviding more intuitive method names. - Alias
Functor - Alias trait for
Functorproviding more intuitive method names. - Alias
Monad - Alias trait for
Monadproviding more intuitive method names. - Alias
Profunctor - Alias trait for
Profunctorproviding more intuitive method names. - Applicative
- The
Applicativetrait extendsFunctorandPureby providing theapplyoperation to apply a function wrapped in a context to a value wrapped in a context. - Bifunctor
- The
Bifunctortrait allows mapping over both arguments of a type constructorF<A, B>. - CoMonad
- The
CoMonadtrait represents a comonadic context, which is the dual of aMonad. - Cybernetic
Loop - The
CyberneticLooptrait 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.
- Effect3
Unbound - Effect3Unbound: Parametric Effect Trait for Arity 3.
- Effect4
Unbound - Effect4Unbound: Parametric Effect Trait for Arity 4.
- Effect5
Unbound - Effect5Unbound: Parametric Effect Trait for Arity 5.
- Foldable
- The
Foldabletrait abstracts over data structures that can be reduced to a single summary value. - Functor
- The
Functortrait 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).
- HKT2
Unbound - Trait for a Higher-Kinded Type (HKT) with two unbound generic parameters (Arity 2).
- HKT3
Unbound - Trait for a Higher-Kinded Type (HKT) with three generic parameters (Arity 3).
- HKT4
Unbound - Trait for a Higher-Kinded Type (HKT) with four generic parameters (Arity 4).
- HKT5
Unbound - Trait for a Higher-Kinded Type (HKT) with five generic parameters (Arity 5).
- HKT6
Unbound - Trait for a Higher-Kinded Type (HKT) with six generic parameters (Arity 6).
- LogAdd
Entry - LogAppend
- Trait for types that can append log entries from another instance of themselves.
- LogEffect
- LogSize
- Monad
- The
Monadtrait extendsFunctorandPureby providing thebindoperation for sequencing computations that produce effectful values. - Monad
Effect3 - Monadic logic for an Arity 3 type after it has been partially applied via
Effect3. - Monad
Effect4 - Monadic logic for an Arity 4 type after it has been partially applied via
Effect4. - Monad
Effect5 - Monadic logic for an Arity 5 type after it has been partially applied via
Effect5. - Monad
Effect3 Unbound - Monadic logic for Parametric Effects (Arity 3 Unbound).
- Monad
Effect4 Unbound - Monadic logic for Parametric Effects (Arity 4 Unbound).
- Monad
Effect5 Unbound - Monadic logic for Parametric Effects (Arity 5 Unbound).
- Parametric
Monad - The
ParametricMonad(or Indexed Monad) trait allows for monadic computations where the type of the underlying state can change at each step. - Profunctor
- The
Profunctortrait represents a type constructor that is contravariant in its first argument and covariant in its second argument. - Promonad
- The
Promonadtrait models the “fusion” or “interaction” of two contexts to produce a third. - Pure
- The
Puretrait provides the ability to lift a value into a context. - Riemann
Map - The
RiemannMaptrait models high-arity geometric interactions, specifically the Riemann Curvature Tensor and Scattering Matrices. - Satisfies
- Marker trait indicating that type
Tsatisfies constraintC. - Traversable
- The
Traversabletrait abstracts over data structures that can be “traversed” or “sequenced” in a way that preserves effects. It combines the capabilities ofFunctor(mapping over elements) andFoldable(reducing to a single value).