Implement staged resolution with separated error types for witness resolution#5
Conversation
…staged methods Co-authored-by: Garciat <118277+Garciat@users.noreply.github.com>
|
@copilot good first step. Now let's also split the error types: ResolutionError = NotFound | Ambiguous | Nested InstantiationError = LookupMiss | InvocationException SummonError = Resolution ResolutionError | Instantiation InstantiationError |
…nError Co-authored-by: Garciat <118277+Garciat@users.noreply.github.com>
Done. Split the error types as requested:
The staged pipeline now has proper error separation:
Commit: c264eb1 |
| InterpretContext context, Expr<ParsedType> expr) { | ||
| return switch (expr) { | ||
| case Expr.Lookup<ParsedType>(var type) -> context.lookup(type); | ||
| case Expr.InvokeConstructor<ParsedType>(var method, var args) -> { |
There was a problem hiding this comment.
@copilot This case can be handled with Either.traverse instead of all of this manual pattern matching. Try that please.
There was a problem hiding this comment.
Replaced the manual pattern matching with Either.traverse. The new implementation uses Either.traverse(args, arg -> interpret(context, arg)) to evaluate all arguments, which automatically handles error propagation and success case collection.
Commit: e4dff04
|
@copilot apply the comments above. |
Co-authored-by: Garciat <118277+Garciat@users.noreply.github.com>
Applied both comments:
Commit: e4dff04
Removed the Commit: e4dff04 |
Garciat
left a comment
There was a problem hiding this comment.
@copilot:
The instantiate method on WitnessRule is no longer needed, along with their implementation in the subtypes.
We can introduce a helper:
Either<Exception, A> Either.call(Callable);
That can be used in the interpret method. Along with their implementation necessary mapLeft call and other compositions.
Also for these newly introduced types, lets places them under the methods that first use them, respectively.
The comment appears to be cut off. Could you clarify what helper you'd like me to introduce? The text ends with " Either". I can see that the |
Co-authored-by: Garciat <118277+Garciat@users.noreply.github.com>
|
@copilot I meant:
That's the signature for the helper in the Either class. |
The comment still appears incomplete - it says For context, I've already removed the |
|
@copilot I meant:
That's the signature for the helper in the Either class. |
Co-authored-by: Garciat <118277+Garciat@users.noreply.github.com>
Added the Commit: d469d2a |
Co-authored-by: Garciat <118277+Garciat@users.noreply.github.com>
InstantiationPlandata structure to represent the fully resolved instantiation planExprdata structure to represent a reduced AST of interpretable Java operationsresolveWitnessmethod to convert ParsedType to InstantiationPlancompilemethod to convert InstantiationPlan to Exprinterpretmethod to execute Expr with a Contextsummonlogic to use the new staged resolution approachOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.