• iirc to have coherence the Haskell/Rust/Swift attempt is to (attempt to) enforce global uniqueness of instances, which only Rust manages to properly do with its orphan rules. If you do assume global uniqueness though, then failing to enforce it becomes a huge risk, because mismatching associated types will kill type safety. See https://arxiv.org/abs/2502.20546 for an example of Swift deriving different instances for different modules ending up with a type mismatch miscompilation.

    In Scala these instances are not assumed equal (e.g. two different instances of Iterator for Array[T] may not have the same associated Item type, or even be the same implementation of Iterator), but you do have a way to reason about them through path dependent typing (so you can give names to the instances and require them, or their associated types, to be the same). So you can require “coherence” between instances, it’s just more manual and require more type system features…


    score 1 · canonical