ML Community Day is November 9! Join us for updates from TensorFlow, JAX, and more Learn more


Returns a function that determines if an expression matches the given pattern.

matcher is a single-dispatch function so its behavior can be overridden for any type. Its default implementation uses Python equality to determine if a pattern matches an expression.

pattern A Python object that describes a set of expressions to match.

A function that takes in three arguments: 1. an expression expr to be matched against, 2. a dictionary mapping names to values bindings that encapsulate the results of matches made up to this point, and 3. succeed, a continuation function that takes in bindings and returns an iterator. The function returns an iterator over bindings. By default, the match is successful if expr matches pattern using Python equality. For more details, refer to the matcher module docstring.