Skip to content
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

introducing unit result in grounded functions #452

Merged
merged 2 commits into from
Oct 4, 2023
Merged

introducing unit result in grounded functions #452

merged 2 commits into from
Oct 4, 2023

Conversation

Necr0x0Der
Copy link
Collaborator

No description provided.

@Necr0x0Der
Copy link
Collaborator Author

This is an attempt to address the issue #390 (or the first step towards it without introducing chaining, which might be already done in Minimal MeTTa).
Some remarks:

  • From the category-theoretic point of view, () is a unit, and (->) is a unit type, so I used them.
  • I’m not sure if there is a way to introduce UNIT_ATOM and UNIT_TYPE as constants in Rust; please, make it prettier if possible;
  • It is not precisely clear if nop should return an empty result or unit. At first, I encountered the test, in which the empty result is useful. But later I encountered two tests, where unit is more convenient. Thus, I made nop into returning unit. Then, I found one more test requiring nop to return the empty result.... I used (superpose ()) instead of (nop) in these cases, and kept nop with unit return type. But if someone has strong preferences, this can be changed.
  • () is used in Python and MeTTa scripts, thus UNIT is used only as an alias in Rust for now. Not sure if we need special symbols for unit and unit types in MeTTa. Personally, I find () and (->) convenient and transparent enough, but special names/symbols might also be convenient. Not sure.

Please, @vsbogd take a look in sense if this is a right direction towards bridging the gap with Minimal MeTTa, and will changes in Minimal MeTTa to adopt this approach (explicit unit) be convenient, or something else should be done?

@Necr0x0Der Necr0x0Der requested a review from vsbogd October 4, 2023 11:09
Copy link
Collaborator

@vsbogd vsbogd left a comment

Choose a reason for hiding this comment

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

I’m not sure if there is a way to introduce UNIT_ATOM and UNIT_TYPE as constants in Rust; please, make it prettier if possible;

Yeah, I believe it is not possible for now, thus keeping them as functions is ok

It is not precisely clear if nop should return an empty result or unit.

I feel nop has two roles in Rust MeTTa interpreter. In minimal MeTTa to get empty result one can use Empty instead. Thus keeping nop as an atom which consumes the result and returns unit is ok with me.

() is used in Python and MeTTa scripts

Probably makes sense taking into account it is easy to instantiate unit in Python comparing to Rust.

Please, @vsbogd take a look in sense if this is a right direction towards bridging the gap with Minimal MeTTa, and will changes in Minimal MeTTa to adopt this approach (explicit unit) be convenient, or something else should be done?

Yes, it looks absolutely aligned with minimal MeTTa implementation, thus I am ready to merge. There is a minor thing: I would move UNIT definitions into the metta module but I can do it after merge in a commit adapting minimal MeTTa branch to this change.

@vsbogd vsbogd merged commit a4470cc into main Oct 4, 2023
1 check passed
@vsbogd vsbogd deleted the unittype branch October 4, 2023 19:10
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.

2 participants