Friday, August 22, 2025

Uncertain⟨T⟩

Mattt Thompson:

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 definitive true or false. You get an Uncertain<Bool> that represents the probability of the comparison being true.

[…]

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.

Comments RSS · Twitter · Mastodon

Leave a Comment