package tezos-micheline-rewriting

  1. Overview
  2. Docs
type head

The type of primitives.

type path

The type of paths.

type t

The type of patterns.

type plist

The type of a pattern on a list of terms.

type node

Micheline nodes.

val pattern_matches : t -> node -> bool

Returns true iff a pattern matches a node.

val all_matches : t -> node -> path list

Returns all matches of a pattern in a node.

val focus_matches : t -> path list -> path list

focus_matches patt matches converts a list of matches for a contextual pattern patt into the list of matches for the focused sub-pattern. Returns the empty list if there is no focused subpattern.

val int : (Z.t -> bool) option -> t

Matches an integer, with an optional predicate.

val string : (string -> bool) option -> t

Matches a string, with an optional predicate.

val bytes : (Bytes.t -> bool) option -> t

Matches a bytes, with an optional predicate.

val prim : head -> plist -> t

prim hd subpatts constructs a pattern matching a primitive application with primitive equal to head and the specified subterms pattern subpatts.

val prim_pred : (head -> bool) -> plist -> t

More general version of prim where an arbitrary predicate on primitives can be used.

val seq : plist -> t

Matches a seq node with a specified subterms pattern.

val any : t

Matches anything.

val focus : t -> t

Flags a pattern as being a focus of the pattern. There can be several foci per pattern but they cannot be nested (an error is raised in this case).

val list_any : plist

Matches any list of patterns.

val list_empty : plist

Matches the empty list of pattern.

val list_cons : t -> plist -> plist

Matches a nonempty list of pattern.

val (@.) : t -> plist -> plist

Alias for list_cons

val pp : Format.formatter -> t -> unit

Pretty-printing.

val uid : t -> int

Returns a unique id for patterns. Two patterns with the same uid are physically equal, but not necessarily the other way around (except in hash-consing mode).