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

  • applicative: Defines the Applicative trait.
  • effect: Defines traits (Effect3, Effect4, Effect5) for partially applying HKTs to build type-encoded effect systems.
  • extensions: Provides concrete HKT witness implementations for standard Rust types like Option, Result, and Vec.
  • foldable: Defines the Foldable trait.
  • functor: Defines the Functor trait.
  • hkt: Defines the core HKT traits (HKT, HKT2, HKT3, HKT4, HKT5) and Placeholder.
  • monad: Defines the Monad trait.
  • monad_effect: Defines traits (MonadEffect3, MonadEffect4, MonadEffect5) for monadic operations within type-encoded effect systems.
  • 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§

OptionWitness
Re-exports OptionWitness, the HKT witness for Option<T>. 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
Re-exports Placeholder, a zero-sized type used in HKT witness implementations. A zero-sized type used purely as a marker or placeholder when implementing Higher-Kinded Type (HKT) traits for concrete types.
ResultWitness
Re-exports ResultWitness, the HKT witness for Result<T, E>. 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.
VecWitness
Re-exports VecWitness, the HKT witness for Vec<T>. 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§

Applicative
Re-exports the Applicative trait for applying functions within a context. The Applicative trait extends Functor by providing methods to apply a function wrapped in a context to a value wrapped in a context, and to lift a pure value into the minimal context.
Effect3
Re-exports the Effect3 trait for arity-3 type-encoded effect systems. Effect3: The Bridge Trait for Arity 3 Type Constructors.
Effect4
Re-exports the Effect4 trait for arity-4 type-encoded effect systems. Effect4: The Bridge Trait for Arity 4 Type Constructors.
Effect5
Re-exports the Effect5 trait for arity-5 type-encoded effect systems. Effect5: The Bridge Trait for Arity 5 Type Constructors.
Foldable
Re-exports the Foldable trait for reducing data structures. The Foldable trait abstracts over data structures that can be reduced to a single summary value.
Functor
Re-exports the Functor trait for mapping over type constructors. The Functor trait abstracts over types that can be mapped over.
HKT
Re-exports the core HKT trait for arity-1 Higher-Kinded Types. Trait for a Higher-Kinded Type (HKT) with one type parameter (arity 1).
HKT2
Re-exports the HKT2 trait for arity-2 Higher-Kinded Types. Trait for a Higher-Kinded Type (HKT) with two type parameters (arity 2).
HKT3
Re-exports the HKT3 trait for arity-3 Higher-Kinded Types. Trait for a Higher-Kinded Type (HKT) with three type parameters (arity 3).
HKT4
Re-exports the HKT4 trait for arity-4 Higher-Kinded Types. Trait for a Higher-Kinded Type (HKT) with four type parameters (arity 4).
HKT5
Re-exports the HKT5 trait for arity-5 Higher-Kinded Types. Trait for a Higher-Kinded Type (HKT) with five type parameters (arity 5).
Monad
Re-exports the Monad trait for sequencing effectful computations. The Monad trait extends Applicative by providing a bind operation for sequencing computations that produce effectful values.
MonadEffect3
Re-exports the MonadEffect3 trait for monadic operations in arity-3 effect systems. Monadic logic for an Arity 3 type after it has been partially applied via Effect3.
MonadEffect4
Re-exports the MonadEffect4 trait for monadic operations in arity-4 effect systems. Monadic logic for an Arity 4 type after it has been partially applied via Effect4.
MonadEffect5
Re-exports the MonadEffect5 trait for monadic operations in arity-5 effect systems. Monadic logic for an Arity 5 type after it has been partially applied via Effect5.