Term.Pattern
External contextual LF term patterns.
type t =
| Variable of {
location : Syncom.Location.t;
identifier : Syncom.Identifier.t;
}
Variable { identifier = "x"; _ }
is the LF-bound variable pattern "x"
.
| Meta_variable of {
location : Syncom.Location.t;
identifier : Syncom.Identifier.t;
}
Meta_variable { identifier = "x"; _ }
is the term-level meta-variable pattern "x"
.
| Parameter_variable of {
location : Syncom.Location.t;
identifier : Syncom.Identifier.t;
}
Parameter_variable { identifier = "#x"; _ }
is the term-level parameter variable pattern with name "#x"
.
| Constant of {
location : Syncom.Location.t;
identifier : Syncom.Qualified_identifier.t;
}
Constant { identifier = "c"; _ }
is the term-level constant pattern "c"
.
| Wildcard of {
location : Syncom.Location.t;
}
Wildcard _
is the term-level catch-all pattern _
.
| Tuple of {
location : Syncom.Location.t;
terms : t Support.List1.t;
}
Tuple { terms; _ }
is the tuple pattern <p1; p2; ...; pn>
if terms = [p1; p2; ...; pn]
.
| Projection of {
location : Syncom.Location.t;
term : t;
projection : [ `By_identifier of Syncom.Identifier.t
| `By_position of Support.Int.t ];
}
Projection { term; _ }
is the pattern for the projection of a tuple term
. This projection is used to indicate which element of a tuple the scrutinee is matched against in a case
-expression. This is typically used for parameter variable patterns such as #p.1
.
| Abstraction of {
location : Syncom.Location.t;
parameter_identifier : Syncom.Identifier.t Support.Option.t;
parameter_type : Typ.t Support.Option.t;
body : t;
}
Abstraction { parameter_identifier = Option.Some "x"; parameter_type = Option.Some t; body; _ }
is the pattern \x:t. body
.
| Substitution of {
location : Syncom.Location.t;
term : t;
substitution : Substitution.t;
}
Substitution { term; substitution; _ }
is the pattern term[substitution]
.
| Application of {
location : Syncom.Location.t;
applicand : t;
arguments : t Support.List1.t;
}
Application { applicand; arguments; _ }
is the term-level application pattern of applicand
with arguments
.
If applicand = Pattern.Constant _
with resolved operator description operator
, then List1.length arguments = Operator.arity operator
.
| Type_annotated of {
location : Syncom.Location.t;
term : t;
typ : Typ.t;
}
Type_annotated { term = x; typ = t; _ }
is the pattern x : t
.