jon.recoil.org

Module Flambda2_identifiers.Coercion0

Defines coercions and their basic operations. For us, a coercion is a compile-time function on simple expressions that serves to add information to a type. A coercion must:

  1. have an inverse (which is also a coercion), and
  1. not alter the run-time value of its argument.

Rule #1 allows us to treat a coerced name as an alias of the original name, since "is an alias of" remains an equivalence relation. Rule #2 means that a coerced Simple.t is still a valid Simple.t, since it's still a register- sized value that we can substitute for free.

Currently, we only use coercions to track the recursion depths of closures, but any type-level tweak that we want to attach to a term could be made a constructor of t, so long as it follows the rules.

module type S = sig ... end