There is a research branch of Scala 3 that contains a feature called Capture Checking. Capture Checking is a way to track effects in a way that works well in imperative code.
Instead of relying on monadic composition the way other contemporary functional languages do, Scala 3 annotates variable types with capability sets, which define what effects and objects a value is allowed to access. It seems to be inspired by Borrow Checking in Rust and looks very similar.
I’ve long found it somewhat ironic that Scala was less safe than Java because it did away with checked exceptions. This finally gives it checked exceptions back.