Module Bigraph.Ctrl

Operations on bigraphical controls.

type param =
  1. | Val of Expr.vals
    (*

    Values

    *)
  2. | Expr of Expr.exp
    (*

    Expression

    *)
  3. | Cons of string option * Expr.cons
    (*

    Bracket guard: the capture name, or None for a nameless guard. The name is bound into the reaction bindings at match time only when present.

    *)

The type of control parameters.

type t

The type of bigraph controls.

val pp : Ppx_deriving_runtime.Format.formatter -> t -> Ppx_deriving_runtime.unit
val to_yojson : t -> Yojson.Safe.t
val of_yojson : Yojson.Safe.t -> t Ppx_deriving_yojson_runtime.error_or
val make : string -> ?params:param list -> int -> t

make s ~params i creates a control named s of arity i with parameters params (defaults to []). Name s must match the following regexp: "^[A-Z][a-zA-Z0-9_']*$". Note: no check is performed.

val arity : t -> int

arity c returns the arity of control c.

val compare : t -> t -> int

Compares controls. Equal names imply equal arities and parameter types. Parameters are compared structurally. No check is performed.

val equal : t -> t -> bool

Equality for type Ctrl.t.

val hash : t -> int

Hash consistent with compare.

val compare_signature : t -> t -> int

Signature comparison: name and arity only, parameters ignored.

val same_signature : t -> t -> bool

same_signature c1 c2 is true when c1 and c2 have the same name and arity, ignoring parameter differences.

val hash_signature : t -> int

Hash consistent with compare_signature.

val matches : pattern:t -> target:t -> bool

Directional pattern matching. Checks name, arity, and parameter compatibility. A Cons pattern matches a Val target when the constraint is satisfied; two Vals match when equal.

val show : t -> string

Return a string containing the name of a control and the values of its parameters. For example, "A(3.4,4)".

val name : t -> string

name c returns the name of control c, i.e. parameters are dropped.

val params : t -> param list

Return the list of parameters of a control.

val eval_exprs : Expr.env -> t -> t

Evaluate a control's parameters within the given environment to allow lazy eval.

val ground_exprs : Expr.env -> string list -> t -> t

Ground the Expr parameters that reference a name in names: each is evaluated against the env bindings restricted to names and becomes a Val (an unbound reference raises Expr.EXP_ERROR, as the corresponding enumerated rule would). Parameters not referencing a names keep their current semantics: a Val is a value check, an Expr is a name-blind wildcard. Used on the condition patterns of factored rules: grounding makes the pattern identical to the corresponding family member's stored pattern.

val match_and_bind : pattern:t -> target:t -> bool * (string * Expr.vals) list

Single-pass match and bind. Returns (true, bindings) on success, (false, []) on mismatch.