Trait veloren_common::typed::SynthTyped
source · pub trait SynthTyped<Context, Target> {
type Expr;
}
Expand description
Given a head expression (Self) and a target type (Type), attempt to synthesize a term that reduces head into the target type.
How we do this depends on the type of the head expression:
-
For enums, we synthesize a match on the current head. For each match arm, we then repeat this process on the constructor arguments; if there are no constructor arguments, we synthesize a literal (Pure term). (TODO: Handle larger than 1 tuple properly–for now we just synthesize a Pure term for these cases).
-
For structs, we synthesize a projection on the current head. For each projection, we then repeat this process on the type of the projected field.
-
For other types (which currently have to opt out during the field declaration), we synthesize a literal.
TODO: Differentiate between the context and the stack at some point; for now, we only use the context as a stack.