-
Notifications
You must be signed in to change notification settings - Fork 5
Refactor types related to App Data #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
fc3d18a to
cf00597
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors and unifies application data types, simplifies type representation, and updates AVM logic to use the new structures.
- Introduces
SomeTypein the Prelude for unified type wrappers and moves argument types into it. - Simplifies
TypeRepby removingConstr.Rep, addingtryCast/beq_generic, and providing new instances. - Refactors AVM classes and translation to use
SomeTypeand a singleClass.AppDatafor action logic.
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Prelude/TypeRep.lean | Removed Constr.Rep, simplified Rep and decidable equality, added tryCast and beq_generic. |
| Prelude/SomeType.lean | Added SomeType wrapper with TypeRep and BEq instances, and casting. |
| Prelude/Base.lean | Updated BoolCheck API to use Bool literals and implicit type args. |
| Prelude.lean | Imported the new SomeType. |
| Apps/UniversalCounter.lean | Updated class label and field definitions to use SomeType. |
| Applib.lean | Adjusted defMethod/defConstructor signatures to use .Args.type. |
| Anoma/Resource.lean | Switched Resource to SomeType for Val/Label and updated fields. |
| Anoma/ConsumedCreated.lean | Replaced True/False with true/false in state checks. |
| AVM/Object.lean | Adapted Object and SomeObject to new SomeType–based private/public fields. |
| AVM/Class/Translation.lean | Rewrote action creation and logic to use Class.AppData and SomeType.cast. |
| AVM/Class/Member/Logic.lean | Updated resource-data checks to use === and SomeType.cast. |
| AVM/Class/Member.lean | Simplified member definitions to use .Args.type. |
| AVM/Class/Label.lean | Replaced Private/Public with SomeType, added MemberId, BEq instances. |
| AVM/Class/AppData.lean | Introduced AppData and SomeAppData for uniform action data. |
| AVM/Class.lean | Streamlined Class struct to reference Class.Logic.Args and new AppData. |
Comments suppressed due to low confidence (6)
Prelude/TypeRep.lean:32
- [nitpick] The variable name
constrsAis a remnant of the oldConstr.Repstructure and may confuse readers—consider renaming it toparamsAor similar for clarity.
let paramsDecEq : Decidable (constrsA = constrsB) := @List.hasDecEq _ Rep.decEq constrsA constrsB
Prelude/SomeType.lean:13
- [nitpick] Comparing
SomeTypeby checking onlyTypeRep.repmay not always reflect the actualBEqsemantics of the underlyingtype; consider leveraginginstBEqon values directly or clarifying this design.
beq a b := a.instTypeRep.rep == b.instTypeRep.rep
Prelude/SomeType.lean:21
SomeType.castis a key part of the new type-casting infrastructure but has no accompanying tests; consider adding unit tests for successful and failed casts between known types.
def SomeType.cast {A B : SomeType} (a : A.type) : Option B.type :=
AVM/Class/Label.lean:33
- The
falseLogicIdcase is introduced without explanation; consider adding a comment describing its purpose as a sentinel for non-logic app data.
| falseLogicId : MemberId lab
AVM/Class/AppData.lean:23
- [nitpick] The
AppDataequality instance uses===and==interchangeably; for consistency, prefer one operator and document its intended use in this context.
instance AppData.hasBEq {lab : Label} : BEq (Class.AppData lab) where
AVM/Class/Translation.lean:146
logic'is a central helper with non-trivial control flow; adding a docstring or inline comments explaining each branch and the role ofcheckMemberLogicwould improve readability.
private def logic' (lab : Label) (cls : Class lab) (args : Class.Logic.Args lab) : Bool :=
AppDatatypes into a singleClass.AppDatatype.ArgsTypesto prelude, renaming it toSomeType. Adds infrastructure to deal withSomeTypeand encapsulates several types into it.Class.logic.TypeRepand removes the incomplete meta-level implementation ofderive_type_rep.SomeObject.fromResource