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:
- have an inverse (which is also a coercion), and
- 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 ... endmodule Make
(Rec_info_expr : Flambda2_identifiers.Rec_info_expr0.S) :
Flambda2_identifiers.Coercion0.S
with type variable = Rec_info_expr.variable
and type rec_info_expr = Rec_info_expr.t