6 releases
Uses new Rust 2024
| new 0.0.6 | Feb 9, 2026 |
|---|---|
| 0.0.5 | Jan 22, 2026 |
| 0.0.3 | Dec 31, 2025 |
#6 in #heterogeneous
1MB
16K
SLoC
DeepCausality Effects
DeepCausality Effects provides a unified type system for building heterogeneous causal graphs. It introduces the EffectData enum, which acts as a versatile container for various data types, enabling the core deep_causality engine to reason across diverse domains within a single graph structure.
Overview
In complex systems, causal effects often appear in different forms: simple boolean triggers, continuous scalar values, multi-dimensional tensors, or geometric algebra constructs. deep_causality_effects solves the challenge of strictly typed homogeneous graphs by providing a "Sum Type" wrapper that encapsulates this complexity.
The crate is designed around the "Atomic + Escape Hatch" pattern:
- Atomic Variants: Efficient handling of common primitives (
bool,f64,i64). - Unified Numerics: A
NumericValuetype covering the full range of Rust's integer and float types. - Algebraic & Topological Types: Native support for
MultiVector,CausalTensor,PointCloud,SimplicialComplex, andManifold. - Escape Hatch: A type-erased
Customvariant (Arc<dyn Any>) for arbitrary complex structures.
Features
- Heterogeneity: Mix and match data types in a single
CausalVecorCausalGraph. - Zero-Copy Cloning: The
Customvariant usesArcfor cheap cloning of complex data. - Algebraic Support: Native integration with
deep_causality_tensoranddeep_causality_multivector. - Topology Support: Native integration with
deep_causality_topology(PointClouds, Complexes, Manifolds). - Ergonomics: Extensive
From<T>implementations for seamless type conversion.
Usage
Add this to your Cargo.toml:
[dependencies]
deep_causality_effects = "0.0.1"
Examples
Basic Usage
use deep_causality_effects::{EffectData, NumericValue};
fn main() {
// Boolean Effect
let activation: EffectData = true.into();
// Numeric Effect (using generic wrapper)
let scalar: EffectData = NumericValue::F64(42.0).into();
// Collection
let vec_effect: EffectData = vec![activation, scalar].into();
}
Algebraic Types
use deep_causality_effects::EffectData;
use deep_causality_tensor::CausalTensor;
use deep_causality_multivector::CausalMultiVector;
fn main() {
// Geometric Algebra MultiVector (2D Euclidean)
let mv = CausalMultiVector::<f64>::new_euclidean(vec![1.0, 0.0, 0.0, 0.0], 2);
let mv_effect: EffectData = mv.into();
// Tensor
let tensor = CausalTensor::<f64>::new(vec![1.0, 2.0], vec![2]).unwrap();
let tensor_effect: EffectData = tensor.into();
}
Topology Types
use deep_causality_effects::EffectData;
use deep_causality_tensor::CausalTensor;
use deep_causality_topology::{PointCloud, SimplicialComplex, Manifold};
fn main() {
// Point Cloud
let points = CausalTensor::<f64>::new(vec![1.0, 2.0, 3.0, 4.0], vec![2, 2]).unwrap();
let meta = CausalTensor::<f64>::new(vec![0.0, 1.0], vec![2]).unwrap();
let pc = PointCloud::new(points, meta, 0).unwrap();
let effect: EffectData = pc.into();
}
Custom Types
For types not natively covered, use the Custom variant:
use deep_causality_effects::EffectData;
#[derive(Debug, PartialEq)]
struct UserProfile {
id: u64,
role: String,
}
fn main() {
let profile = UserProfile { id: 1, role: "Admin".into() };
// Wrap in EffectData
let effect = EffectData::from_custom(profile);
// Downcast when needed
if let Some(p) = effect.as_custom::<UserProfile>() {
assert_eq!(p.role, "Admin");
}
}
Architecture
The EffectData enum is defined as:
pub enum EffectData {
Bool(bool),
Float(f64),
Int(i64),
String(String),
Vector(Vec<EffectData>),
Numerical(NumericValue), // Covers u8-u128, i8-i128, f32
MultiVector(CausalMultiVector<f64>),
Tensor(CausalTensor<f64>),
PointCloud(PointCloud<f64>),
SimplicialComplex(SimplicialComplex),
Manifold(Manifold<f64>),
Custom(Arc<dyn Any + Send + Sync>),
}
License
This project is licensed under the MIT license.
Dependencies
~1MB
~17K SLoC