1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//! `OrdoFP` Nexus: Efficient Type-Level Effect System
//!
//! Nexus provides a type-level effect system for Rust with efficient
//! representations for common effect patterns.
//!
//! # Design Philosophy
//!
//! Nexus is a **pure Rust stable library** that uses const generics for
//! type-level effect tracking. It provides:
//!
//! 1. **Efficient Effect Representations** — Single-effect rows use specialized
//! representations that benchmark within 10% of hand-written equivalents
//! 2. **Typed Optimization Combinators** — Users explicitly opt into optimizations
//! like parallelization via type-safe combinators
//! 3. **Tiered Verification** — From documented laws to optional property tests
//!
//! # What Nexus IS
//!
//! - A library providing `Eff<R, A>` for effectful computations
//! - Type-level effect tracking via const-generic bitmasks
//! - Efficient handlers for State, Reader, Error, Writer effects
//! - Explicit optimization combinators (`par_map`, memoize, etc.)
//!
//! # What Nexus is NOT
//!
//! - NOT a compiler plugin or language extension
//! - NOT automatic optimization (users must opt-in via combinators)
//! - NOT "zero-cost" in all cases (complex effect combinations use boxing)
//! - NOT formally verified (laws are documented and tested, not proven)
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────────┐
//! │ User Code │
//! │ let result = state_comp.and_then(|x| reader_comp(x)); │
//! └─────────────────────────────────────────────────────────────────┘
//! │
//! ▼
//! ┌─────────────────────────────────────────────────────────────────┐
//! │ Type-Level Effect Row │
//! │ Eff<Row<STATE_BIT | READER_BIT>, A> │
//! └─────────────────────────────────────────────────────────────────┘
//! │
//! ▼
//! ┌─────────────────────────────────────────────────────────────────┐
//! │ Effect-Specific Representations │
//! │ Pure → A | State → fn(S)->(A,S) | Combined → Box<Cont> │
//! └─────────────────────────────────────────────────────────────────┘
//! ```
//!
//! # Performance Characteristics
//!
//! | Effect Pattern | Representation | Expected Overhead |
//! |----------------|----------------|-------------------|
//! | Pure only | Direct value | ~0% |
//! | State only | State-passing function | <5% |
//! | Reader only | Environment-passing function | <5% |
//! | Error only | Result<A, E> | ~0% |
//! | 2 effects | Specialized or boxed | 5-20% |
//! | 3+ effects | Boxed continuation | 20-50% |
//!
//! # Example
//!
//! ```rust
//! use ordofp_core::nexus::prelude::*;
//!
//! // Pure computation - no overhead
//! let pure_comp: Eff<Pure, i32> = pure(42);
//! assert_eq!(pure_comp.run_pure(), 42);
//!
//! // Stateful computation - uses StatefulComputation for efficiency
//! let state_comp = StatefulComputation::<i32, i32>::get()
//! .map(|x| x + 1);
//! let (result, final_state) = state_comp.run(0);
//! assert_eq!(result, 1);
//! assert_eq!(final_state, 0);
//! ```
//!
//! # Feature Flags
//!
//! - `nexus` — Core effect infrastructure (required)
// Core effect infrastructure
// Effect types
// Optimization combinators (explicit opt-in)
/// Benchmark infrastructure for validating effect-overhead acceptance criteria.
///
/// Provides workload drivers ([`bench::measure_baseline`], [`bench::measure_state`],
/// etc.) that run effect-wrapped and hand-written code identically for an outer timing
/// harness (no timing happens in this module), plus semantic verification functions
/// ([`bench::verify_pure_semantics`], etc.) that assert correctness. Use
/// [`bench::OverheadReport`] to express and check target overhead budgets.
// Handler laws and verification (Tier 0-1)
// Runtime verification infrastructure (Tier 2)
// Prelude for convenient imports
// Re-exports
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;