You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- pipeline.md: PureBeam constructors, smap usage, propagate function
- context.md: why Beam uses direct matches instead of Eh
- flight-recorder.md: ScalarLoss on eigenvalue decomposition, Transport holonomy
- migration.md: case study — ShannonLoss to ScalarLoss, constructor methods
- README.md: "See it in action" section linking to prism-core
Copy file name to clipboardExpand all lines: README.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -129,6 +129,10 @@ Block macro for implicit loss accumulation — `eh! { }` will do what `Eh` does
129
129
-[Flight recorder](docs/flight-recorder.md) — `Failure(E, L)` as production telemetry, not stack traces
130
130
-[Benchmarks](docs/benchmarks.md) — 0.65 ns per honest step, zero on the success path
131
131
132
+
## See it in action
133
+
134
+
-**[prism-core](https://github.com/systemic-engineering/prism/tree/main/core)** — spectral optics pipeline. Uses `Imperfect` as the value carrier inside `Beam`, with a custom `ScalarLoss` type for eigenvalue decomposition. 182 tests.
assert_eq!(result.loss().steps(), 2); // the cost of getting here survives
210
210
```
211
211
212
+
## Why prism-core doesn't use Eh
213
+
214
+
prism-core's `Beam` trait IS its own composition context. The `tick` primitive destructures the beam's `Imperfect` to extract inner values for building new beam structs — a pattern that requires direct match arms rather than `Eh`'s `Result`-based extraction.
215
+
216
+
From [`core/src/beam.rs`](https://github.com/systemic-engineering/prism/blob/main/core/src/beam.rs):
Imperfect::Failure(_, _) =>panic!("tick on Err beam — check is_ok() first"),
222
+
Imperfect::Success(old_out) =>PureBeam {
223
+
input:old_out,
224
+
imperfect:next,
225
+
},
226
+
Imperfect::Partial(old_out, loss) =>PureBeam {
227
+
input:old_out,
228
+
imperfect:propagate(loss, next),
229
+
},
230
+
}
231
+
}
232
+
```
233
+
234
+
The beam needs `old_out` to construct the new struct's `input` field. `Eh.eh()` would discard that inner value into a `Result<T, E>`, losing the structural information beam needs.
235
+
236
+
This is the right pattern: `Eh` is for code that consumes `Imperfect` values and produces a final result. `Beam` is for code that builds new `Imperfect` values from old ones while carrying structural context. Different layers, different tools.
237
+
212
238
[Back to README](../README.md) · [Terni-functor →](terni-functor.md)
Copy file name to clipboardExpand all lines: docs/flight-recorder.md
+40Lines changed: 40 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -127,4 +127,44 @@ represent them. The type doesn't have a place to put the information.
127
127
128
128
Those empty cells are why this crate exists.
129
129
130
+
## Real-world: prism-core's ScalarLoss
131
+
132
+
prism-core implements its own `Loss` type — [`ScalarLoss`](https://github.com/systemic-engineering/prism/blob/main/core/src/scalar_loss.rs) — for eigenvalue decomposition. When a spectral projection zeroes out eigenvalues below a precision threshold, the magnitude of what was discarded IS the loss. This is the flight recorder in practice: the loss tells you how much signal was thrown away at each stage of a spectral pipeline.
The two zeroed-out dimensions are measured. The flight recorder captures exactly what was discarded, in bits. Downstream consumers see `Partial` and know: a value exists, but it cost something. The loss says how much.
169
+
130
170
[Back to README](../README.md) · [Loss types →](loss-types.md) · [Benchmarks →](benchmarks.md)
Copy file name to clipboardExpand all lines: docs/migration.md
+36Lines changed: 36 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -166,4 +166,40 @@ assert_eq!(error, "gone");
166
166
assert_eq!(loss.steps(), 7);
167
167
```
168
168
169
+
## Case study: prism-core
170
+
171
+
prism-core migrated from `ShannonLoss` (a former terni type) to a local `ScalarLoss` when terni removed `ShannonLoss` upstream. The migration also replaced manual enum variant constructors with terni's constructor methods.
1.**Own the loss type.** When the upstream type changed, core defined `ScalarLoss` locally — a 39-line file implementing the `Loss` monoid with additive `combine`. No external dependency for a domain-specific measurement.
198
+
199
+
2.**Constructor methods over enum variants.**`Imperfect::failure(e)` replaces `Imperfect::Failure(e, L::zero())` — the zero loss is the common case and shouldn't require spelling out. `Imperfect::failure_with_loss(e, l)` for the rare case where accumulated loss needs explicit attachment.
200
+
201
+
3.**Gradual.** The `Beam` trait's `tick` primitive still pattern-matches on `Imperfect` variants directly — because it needs to destructure the inner values to build new beam structs. The refactor targeted constructors and leaf code, not the pipeline primitive.
202
+
203
+
Total diff: 6 files changed, 27 insertions, 27 deletions. All 182 tests pass unchanged.
204
+
169
205
[Back to README](../README.md) · [Loss types →](loss-types.md)
Copy file name to clipboardExpand all lines: docs/pipeline.md
+53Lines changed: 53 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -171,4 +171,57 @@ assert_eq!(a, b);
171
171
assert_eq!(b, c);
172
172
```
173
173
174
+
## Real-world: prism-core
175
+
176
+
prism-core's `Beam` trait uses `Imperfect` as its value carrier. Every beam carries an `Imperfect<Out, E, L>` internally, and the semifunctor `smap` maps over it using `.eh()`-style closures that return `Imperfect`.
177
+
178
+
From [`core/src/beam.rs`](https://github.com/systemic-engineering/prism/blob/main/core/src/beam.rs) — the `smap` method on the `Beam` trait:
0 commit comments