Guarded methods using equality witnesses

from blog ring.muhokama.fun, | ↗ original
Guarded methods allow constraints to be attached to the receiver (self) only for certain methods, so that these methods can only be called if the receiver satisfies these constraints (these guards). OCaml does not syntactically allow this type of method to be defined directly. In this note, we'll look at how to encode them using a type equality...