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
applicative: Defines theApplicativetrait.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 likeOption,Result, andVec.foldable: Defines theFoldabletrait.functor: Defines theFunctortrait.hkt: Defines the coreHKTtraits (HKT,HKT2,HKT3,HKT4,HKT5) andPlaceholder.monad: Defines theMonadtrait.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§
- Option
Witness - Re-exports
OptionWitness, the HKT witness forOption<T>.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
- 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. - Result
Witness - Re-exports
ResultWitness, the HKT witness forResult<T, E>.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. - VecWitness
- Re-exports
VecWitness, the HKT witness forVec<T>.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§
- Applicative
- Re-exports the
Applicativetrait for applying functions within a context. TheApplicativetrait extendsFunctorby 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
Effect3trait for arity-3 type-encoded effect systems. Effect3: The Bridge Trait for Arity 3 Type Constructors. - Effect4
- Re-exports the
Effect4trait for arity-4 type-encoded effect systems. Effect4: The Bridge Trait for Arity 4 Type Constructors. - Effect5
- Re-exports the
Effect5trait for arity-5 type-encoded effect systems. Effect5: The Bridge Trait for Arity 5 Type Constructors. - Foldable
- Re-exports the
Foldabletrait for reducing data structures. TheFoldabletrait abstracts over data structures that can be reduced to a single summary value. - Functor
- Re-exports the
Functortrait for mapping over type constructors. TheFunctortrait abstracts over types that can be mapped over. - HKT
- Re-exports the core
HKTtrait for arity-1 Higher-Kinded Types. Trait for a Higher-Kinded Type (HKT) with one type parameter (arity 1). - HKT2
- Re-exports the
HKT2trait for arity-2 Higher-Kinded Types. Trait for a Higher-Kinded Type (HKT) with two type parameters (arity 2). - HKT3
- Re-exports the
HKT3trait for arity-3 Higher-Kinded Types. Trait for a Higher-Kinded Type (HKT) with three type parameters (arity 3). - HKT4
- Re-exports the
HKT4trait for arity-4 Higher-Kinded Types. Trait for a Higher-Kinded Type (HKT) with four type parameters (arity 4). - HKT5
- Re-exports the
HKT5trait for arity-5 Higher-Kinded Types. Trait for a Higher-Kinded Type (HKT) with five type parameters (arity 5). - Monad
- Re-exports the
Monadtrait for sequencing effectful computations. TheMonadtrait extendsApplicativeby providing abindoperation for sequencing computations that produce effectful values. - Monad
Effect3 - Re-exports the
MonadEffect3trait for monadic operations in arity-3 effect systems. Monadic logic for an Arity 3 type after it has been partially applied viaEffect3. - Monad
Effect4 - Re-exports the
MonadEffect4trait for monadic operations in arity-4 effect systems. Monadic logic for an Arity 4 type after it has been partially applied viaEffect4. - Monad
Effect5 - Re-exports the
MonadEffect5trait for monadic operations in arity-5 effect systems. Monadic logic for an Arity 5 type after it has been partially applied viaEffect5.