Module Affine.Loop_chain

Enclosing loop chains

An access or effect's enclosing loops form a single nested chain, outermost first. Unlike a routine's sibling loops (Loop_ranges), a single enclosing chain cannot bind the same loop symbol twice: shadowing would make a symbol's range ambiguous between outer and inner binders. Loop_chain.t enforces binder uniqueness at construction with a typed refusal (gh-ocannl-1628).

type t
val sexp_of_t : t -> Sexplib0.Sexp.t
include Ppx_compare_lib.Equal.S with type t := t
val equal : t Base__Ppx_compare_lib.equal
type duplicate = {
  1. symbol : Indexing.symbol;
  2. outer : int * int;
  3. inner : int * int;
}
val sexp_of_duplicate : duplicate -> Sexplib0.Sexp.t
val equal_duplicate : duplicate -> duplicate -> bool
exception Duplicate_binder of duplicate
val empty : t
val is_empty : t -> bool
val length : t -> int
val enter : t -> Indexing.symbol -> (int * int) -> (t, duplicate) Stdlib.Result.t

enter chain s (lo, hi): appends an innermost binder (s, (lo, hi)) to chain (ordered outermost first), refusing a symbol already bound in chain.

val enter_exn : t -> Indexing.symbol -> (int * int) -> t

As enter, raising Duplicate_binder on a duplicate symbol.

val of_bindings : (Indexing.symbol * (int * int)) list -> (t, duplicate) Stdlib.Result.t

Builds a chain from an outermost-first binding list, refusing the first duplicate symbol.

val of_bindings_exn : (Indexing.symbol * (int * int)) list -> t

As of_bindings, raising Duplicate_binder on a duplicate symbol.

val map_symbols : t -> f:(Indexing.symbol -> Indexing.symbol) -> (t, duplicate) Stdlib.Result.t

Renames each bound symbol in order, refusing any rename that collides two binders.

val map_symbols_exn : t -> f:(Indexing.symbol -> Indexing.symbol) -> t

As map_symbols, raising Duplicate_binder on a collision.

val find : t -> Indexing.symbol -> (int * int) option
val mem : t -> Indexing.symbol -> bool
val to_alist : t -> (Indexing.symbol * (int * int)) list

The enclosing binders, outermost first.

val ranges : t -> Loop_ranges.t

The chain viewed as a Loop_ranges.t box environment.