package pyre-ast

  1. Overview
  2. Docs

This module provides a type that represents a pattern for a given match branch. See PEP 622.

type ('constant, 'expr, 'identifier, 'location, 'pattern) t = private {
  1. match_value : location:'location -> value:'expr -> 'pattern;
    (*

    Represent a pattern that matches constants, except None, True, and False literal.

    *)
  2. match_singleton : location:'location -> value:'constant -> 'pattern;
    (*

    Represent a pattern that matches None, True, and False (i.e. literals that are compared by identity instead of equality).

    *)
  3. match_sequence : location:'location -> patterns:'pattern list -> 'pattern;
    (*

    Represent a pattern that matches a sequence of other patterns.

    *)
  4. match_mapping : location:'location -> keys:'expr list -> patterns:'pattern list -> rest:'identifier option -> 'pattern;
    (*

    Represent a pattern that matches a map of patterns.

    *)
  5. match_class : location:'location -> cls:'expr -> patterns:'pattern list -> kwd_attrs:'identifier list -> kwd_patterns:'pattern list -> 'pattern;
    (*

    Represent a pattern that destructuring arbitrary objects.

    *)
  6. match_star : location:'location -> name:'identifier option -> 'pattern;
    (*

    This pattern can only be nested in another match_sequence pattern, representing the "rest" of the sequence

    *)
  7. match_as : location:'location -> pattern:'pattern option -> name:'identifier option -> 'pattern;
    (*

    Represent a capture or wildcard pattern (e.g. case x as y, case x, or case _).

    *)
  8. match_or : location:'location -> patterns:'pattern list -> 'pattern;
    (*

    Represent a pattern that matches a combination of other patterns.

    *)
}
val make : match_value:(location:'a -> value:'b -> 'c) -> match_singleton:(location:'a -> value:'d -> 'c) -> match_sequence:(location:'a -> patterns:'c list -> 'c) -> match_mapping: (location:'a -> keys:'b list -> patterns:'c list -> rest:'e option -> 'c) -> match_class: (location:'a -> cls:'b -> patterns:'c list -> kwd_attrs:'e list -> kwd_patterns:'c list -> 'c) -> match_star:(location:'a -> name:'e option -> 'c) -> match_as:(location:'a -> pattern:'c option -> name:'e option -> 'c) -> match_or:(location:'a -> patterns:'c list -> 'c) -> unit -> ('d, 'b, 'e, 'a, 'c) t

Constructor of t.

OCaml

Innovation. Community. Security.