Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@lukaszcz
Copy link
Collaborator

@lukaszcz lukaszcz commented Jul 4, 2025

  1. Unifies all AppData types into a single Class.AppData type.
  2. Moves ArgsTypes to prelude, renaming it to SomeType. Adds infrastructure to deal with SomeType and encapsulates several types into it.
  3. Simplifies Class.logic.
  4. Simplifies TypeRep and removes the incomplete meta-level implementation of derive_type_rep.
  5. Adds SomeObject.fromResource

@lukaszcz lukaszcz self-assigned this Jul 4, 2025
@lukaszcz lukaszcz force-pushed the refactor-appdata branch from fc3d18a to cf00597 Compare July 4, 2025 13:58
@lukaszcz lukaszcz marked this pull request as ready for review July 7, 2025 11:24
@lukaszcz lukaszcz requested review from Copilot and janmasrovira and removed request for Copilot July 7, 2025 11:24
Copy link
Contributor

Copilot AI left a 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 SomeType in the Prelude for unified type wrappers and moves argument types into it.
  • Simplifies TypeRep by removing Constr.Rep, adding tryCast/beq_generic, and providing new instances.
  • Refactors AVM classes and translation to use SomeType and a single Class.AppData for 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 constrsA is a remnant of the old Constr.Rep structure and may confuse readers—consider renaming it to paramsA or similar for clarity.
        let paramsDecEq : Decidable (constrsA = constrsB) := @List.hasDecEq _ Rep.decEq constrsA constrsB

Prelude/SomeType.lean:13

  • [nitpick] Comparing SomeType by checking only TypeRep.rep may not always reflect the actual BEq semantics of the underlying type; consider leveraging instBEq on values directly or clarifying this design.
  beq a b := a.instTypeRep.rep == b.instTypeRep.rep

Prelude/SomeType.lean:21

  • SomeType.cast is 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 falseLogicId case 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 AppData equality 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 of checkMemberLogic would improve readability.
private def logic' (lab : Label) (cls : Class lab) (args : Class.Logic.Args lab) : Bool :=

@janmasrovira janmasrovira merged commit 987c7c1 into main Jul 7, 2025
2 checks passed
@janmasrovira janmasrovira deleted the refactor-appdata branch July 7, 2025 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants