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

Skip to content

Conversation

@janmasrovira
Copy link
Collaborator

@janmasrovira janmasrovira commented Jul 24, 2025

Changes in the model:

  1. Functions can construct new objects
  2. Functions specify for each object argument whether it should be destroyed or disassembled. Destroyed arguments are balanced with ephemeral resources automatically. Disassembled arguments are meant to be manually balanced by the user in the function.

Apps:

I've extended the kudos bank example with a new class Check. I've added two functions to the ecosystem:

  1. IssueCheck. It subtracts some amount from your bank account and creates a new check for that amount.
  2. DepositCheck. It destroys a check and adds its amount to your bank account.

@janmasrovira janmasrovira self-assigned this Jul 24, 2025
@janmasrovira janmasrovira changed the title Allow functions to construct new objects Allow functions to construct new objects and specify which selves are destroyed/consumed Jul 25, 2025
@janmasrovira janmasrovira requested a review from lukaszcz July 25, 2025 16:33
@janmasrovira janmasrovira marked this pull request as ready for review July 25, 2025 16:33
deriving BEq

structure FunctionResult {lab : Ecosystem.Label} (functionId : lab.FunctionId) : Type (u + 1) where
/-- List of created objects -/
Copy link
Collaborator

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.

Copy link
Collaborator Author

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
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@lukaszcz lukaszcz requested a review from Copilot July 28, 2025 17:42
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 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

@janmasrovira janmasrovira requested a review from lukaszcz July 28, 2025 19:25
@lukaszcz lukaszcz merged commit f42f7a7 into main Jul 29, 2025
2 checks passed
@lukaszcz lukaszcz deleted the function-construct branch July 29, 2025 06:33
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