Knowledge<T>
Sounio’s epistemic value type: explicit unwrap, no silent loss of uncertainty.
Knowledge<T>
Knowledge<T> is Sounio’s epistemic value type: a value paired with metadata about how known it is.
What Works Today (Compiler Reality)
You can construct a Knowledge<T> value and explicitly extract the underlying T:
fn main() with IO {
let k = Knowledge { value: 42.0 }
// Explicit extraction requires a reason string.
let x: f64 = k.unwrap("accepted for demo")
if x == 42.0 {
print("knowledge_unwrap: PASS\n")
} else {
print("knowledge_unwrap: FAIL\n")
}
}
The key property is no silent unwrap: code must say why it’s discarding epistemic information.
In the Spec / Stdlib Design (Full Epistemic Model)
The language specification and stdlib design aim for Knowledge<T> to carry (at least):
- a point estimate (
value: T) - uncertainty (e.g., variance)
- confidence/credibility
- provenance (where it came from, and how it was transformed)
You’ll see this richer model in the stdlib’s epistemic module (and in the formal spec), even if some fields and propagation rules are not enforced in every compiler mode yet.
Practical Guidance
- Prefer passing
Knowledge<T>through your pipeline unchanged. - Only
unwrap(...)at the boundary where you truly need a plainT(and record why).