package yuujinchou

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

The Action module implements the engine running the patterns.

The engine tries to preserve physical equality whenever feasible. For example, if the trie t has a binding at x, the pattern Pattern.renaming["x"] ["x"] on t will return the original t.

Matching

type nonrec ('a, 'error) result = ('a, [> `BindingNotFound of Pattern.path ] as 'error) result

The type of the result. The error `BindingNotFound means that the engine expected at least one binding under path but could not find it.

val run : ?rev_prefix:Pattern.path -> union:(rev_path:Pattern.path -> 'a -> 'a -> ('a, 'error) result) -> unit Pattern.t -> 'a Trie.t -> ('a Trie.t, 'error) result

run ~rev_prefix ~union pattern trie runs the pattern on the trie and return the transformed trie. It ignores patterns created by Pattern.hook.

  • parameter rev_prefix

    The prefix prepended to any path sent to union and any path in the error reporting, but in reverse. The default is the empty unit path ([]).

  • parameter union

    The resolver for two conflicting bindings sharing the same name. Patterns such as Pattern.renaming and Pattern.union could lead to conflicting bindings, and union ~rev_path x y should return the resolution of x and y at the (reversed) path rev_path.

  • returns

    The new trie after the transformation. Error (`BindingNotFound p) means the transformation failed because of the absence of expected bindings. For example, the pattern Pattern.except["x"; "y"] expects that there was already something under the subtree at x.y. If there were actually no names with the prefix x.y, then the pattern will trigger the error `BindingNotFound ["x"; "y"]. The path p is only an approximation---the user might have intended to hide the binding at ["x"; "y"; "z"], a binding under ["x"; "y"], but the engine would never know the user's true intention.

val run_with_hooks : ?rev_prefix:Pattern.path -> union:(rev_path:Pattern.path -> 'a -> 'a -> ('a, 'error) result) -> hooks: ('hook -> rev_prefix:Pattern.path -> 'a Trie.t -> ('a Trie.t, 'error) result) -> 'hook Pattern.t -> 'a Trie.t -> ('a Trie.t, 'error) result

run_with_hooks ~rev_prefix ~hooks ~union pattern trie runs the pattern on the trie and return the transformed trie. It is similar to run but accepts an additional argument hooks to handle the patterns created by Pattern.hook.

  • parameter rev_prefix

    Same as the parameter rev_prefix for run.

  • parameter union

    Same as the parameter union for run.

  • parameter hooks

    The hooks that will be triggered by patterns created by Pattern.hook. When the engine encounters the pattern Pattern.hookh, it will call hooks h ~rev_path:p t on the current trie where p is the path (in reverse) and t is the subtrie at p.

Pretty Printers

val pp_path : Format.formatter -> Pattern.path -> unit

Pretty printer for path.

OCaml

Innovation. Community. Security.