-
Notifications
You must be signed in to change notification settings - Fork 5
Allow functions to construct new objects and specify which selves are destroyed/consumed #65
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
83684d2 to
8182c61
Compare
8182c61 to
38ebfc5
Compare
6b28582 to
4f1f250
Compare
AVM/Ecosystem/Member.lean
Outdated
| deriving BEq | ||
|
|
||
| structure FunctionResult {lab : Ecosystem.Label} (functionId : lab.FunctionId) : Type (u + 1) where | ||
| /-- List of created objects -/ |
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.
Should we change the comment when we changed the field name? Maybe we should explain what "assembled" means.
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.
comment added
| def splitsExact (lst : List A) (lengths : List Nat) : Option (SplitsType A lengths) := | ||
| match splits lst lengths with | ||
| | .some (_, []) => none | ||
| | _ => none |
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.
Something is wrong here. The result of splitsExact is always none.
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.
fixed
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 enhances the function system to support object construction and destruction, extending beyond just assembly/disassembly operations. It introduces explicit control over how function arguments are handled - whether they should be destroyed (with automatic ephemeral resource balancing) or disassembled (requiring manual balancing).
Key changes include:
- Functions can now construct new objects in addition to assembling existing ones
- Functions specify destruction/disassembly behavior for each object argument
- Enhanced the KudosBank example with a Check class and related transfer operations
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Apps/KudosBank.lean | Adds Check class with transfer functionality and IssueCheck/DepositCheck functions demonstrating new construction/destruction patterns |
| AVM/Ecosystem/Member.lean | Introduces DeconstructionKind enum and updates FunctionResult to support constructed objects and argument deconstruction specification |
| AVM/Action.lean | Updates action creation to include memberData parameter and adds balance methods for constructed/destroyed objects |
| AVM/Ecosystem/AppData.lean | Adds FunctionData structure and memberData field to AppData for storing function metadata |
| AVM/Ecosystem/Translation.lean | Updates function logic and action creation to handle constructed objects and argument deconstruction tracking |
17cc43b to
d55a780
Compare
Changes in the model:
Apps:
I've extended the kudos bank example with a new class
Check. I've added two functions to the ecosystem:IssueCheck. It subtracts some amount from your bank account and creates a new check for that amount.DepositCheck. It destroys a check and adds its amount to your bank account.