TaglessFinal.Pattern
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 {
match_value : location:'location -> value:'expr -> 'pattern;
Represent a pattern that matches constants, except None
, True
, and False
literal.
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).
match_sequence : location:'location -> patterns:'pattern list -> 'pattern;
Represent a pattern that matches a sequence of other patterns.
*)match_mapping : location:'location ->
keys:'expr list ->
patterns:'pattern list ->
rest:'identifier option ->
'pattern;
Represent a pattern that matches a map of patterns.
*)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.
*)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
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 _
).
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
.