Module Environment.Recursive

A Recursive.t is a mapping from Fix_id.t to a copy of the environment at the point where the Fix_define for that Fix_id.t was evaluated, as well as the resolved May_contain for that Fix_define.

Why do we have enough information when gathering a Fix_define to resolve its dependencies? A Fix_define can only contain Fix_recurses corresponding to itself and any enclosing Fix_defines. The outermost Fix_define has no enclosing Fix_defines and therefore we can resolve it: it resolves to the May_contain of its body ignoring the recursive dependency on itself. Induction on the number of enclosing Fix_defines proves we can resolve _any_ Fix_define's May_contain.

type env := t
type entry = {
  1. environment : env;
  2. resolved_contain : May_contain.Resolved.t;
}
type t
val empty : t
val add_exn : t -> key:'a Fix_id.t -> data:entry -> t
val add_overwriting : t -> key:'a Fix_id.t -> data:entry -> t
val find_exn : t -> 'a Fix_id.t -> entry
val resolve_may_contain : t -> May_contain.Unresolved.t -> May_contain.Resolved.t

resolve_may_contain takes a t and a May_contain.Unresolved.t and looks up any required information about the resolved_contain of any recursive dependencies to resolve it.