Your First Program
A small end-to-end program that compiles today, plus the spec-level epistemic version.
Your First Program
This page shows two versions of the same idea:
- A program that compiles and runs today with the current
souctoolchain - The spec-level epistemic version (where uncertainty + units are fully enforced)
Version A: Compiles Today (Knowledge + Explicit Unwrap)
In the current compiler, Knowledge<T> exists, and extracting the underlying value is explicit via unwrap(reason).
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")
}
}
Run it:
souc run first_program.sio
Version B: Spec-Level Epistemic BMI (Aspirational)
The language specification and stdlib design support:
- units of measure (e.g.,
kg,m) - measurements with uncertainty
- confidence-based control flow
When those pieces are fully integrated, the same idea looks like:
fn main() with IO {
// Spec-level sketch (not all pieces are enforced by the compiler yet)
let mass: Knowledge<f64> = measure(value: 75.3, variance: 0.5 * 0.5, source: "scale")
let height: Knowledge<f64> = measure(value: 1.82, variance: 0.01 * 0.01, source: "tape")
let bmi = mass / (height * height)
if bmi.confidence > 0.90 {
println("BMI is safe to use for a decision")
} else {
println("BMI is too uncertain")
}
}
What’s Next?
- Learn Epistemic Types
- Read
Knowledge<T> - Explore Effects