Module Frontend.Environment

Type environments used during typechecking. Maps from strings to function or variable information

type originblock =
  1. | MathLibrary
  2. | Functions
  3. | Data
  4. | TData
  5. | Param
  6. | TParam
  7. | Model
  8. | GQuant

Origin blocks, to keep track of where variables are declared

type varinfo = {
  1. origin : originblock;
  2. global : bool;
  3. readonly : bool;
}

Information available for each variable

type info = {
  1. type_ : Middle.UnsizedType.t;
  2. kind : [ `Variable of varinfo | `UserDeclared of Middle.Location_span.t | `StanMath | `UserDefined ];
}
type t
val stan_math_environment : t

A type environment which contains the Stan math library functions

val find : t -> string -> info list
val add : t -> string -> Middle.UnsizedType.t -> [ `UserDeclared of Middle.Location_span.t | `StanMath | `UserDefined | `Variable of varinfo ] -> t

Add a new item to the type environment. Does not overwrite existing, but shadows

val set_raw : t -> string -> info list -> t

Overwrite the existing items bound to a name

val mem : t -> string -> bool
val iteri : t -> (string -> info list -> unit) -> unit
val nearest_ident : t -> string -> string option

The nearest identifier by edit distance, capped at edit distance 3 (if one exists)