Uncertain⟨T⟩
In 2014, researchers at the University of Washington and Microsoft Research proposed a radical idea: What if uncertainty were encoded directly into the type system? Their paper, Uncertain<T>: A First-Order Type for Uncertain Data introduced a probabilistic programming approach that’s both mathematically rigorous and surprisingly practical.
As you’d expect for something from Microsoft in the 2010s, the paper is implemented in C#. But the concepts translate beautifully to Swift.
[…]
When you compare two
Uncertain
values, you don’t get a definitivetrue
orfalse
. You get anUncertain<Bool>
that represents the probability of the comparison beingtrue
.[…]
Using an abstraction like
Uncertain<T>
forces you to deal with uncertainty as a first-class concept rather than pretending it doesn’t exist. And in doing so, you end up with much smarter code.