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

Add PlutusTx.Data.List.destructList #6945

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Add PlutusTx.Data.List.destructList #6945

wants to merge 3 commits into from

Conversation

zliu41
Copy link
Member

@zliu41 zliu41 commented Mar 12, 2025

This seems not only useful for @adamsmo's scripts, but also useful in general. See Haddock for more details.

Closes #6936

@zliu41 zliu41 requested a review from a team March 12, 2025 14:53
@zliu41 zliu41 changed the title Add PlutusTx.Utils.TH.destructBuiltinList Add PlutusTx.Data.List.destructList Mar 19, 2025
@zliu41 zliu41 requested a review from Unisay March 19, 2025 03:50
((\tail -> tail (tail (force tailList nt)))
(\eta -> force tailList eta)))
(unIData (force headList nt)))
(force tailList (unListData d))))
Copy link
Contributor

Choose a reason for hiding this comment

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

That's a lot of forcing, why not bind force tailList and force headList to a variable? Or do you expect CSE to clean it up? Particularly when you already seem to do that in (\eta -> force tailList eta). Why the eta-expansion btw?

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't CSE work-free terms such as force tailList. As mentioned in the CSE Note, doing so may reduce size but always increases cost, and CSE currently favors smaller cost. I don't think there is a way to manually bind force tailList to a variable, is there?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not really work-free, since both Force and Builtin have a cost. Var has a cost too, but it's 1 against 2, so binding it to a variable should be an overall cost reduction.

I don't think there is a way to manually bind force tailList to a variable, is there?

I don't know.

Copy link
Member Author

@zliu41 zliu41 Mar 20, 2025

Choose a reason for hiding this comment

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

There's also LamAbs and App, though perhaps if a builtin is forced many times, it may be worth hoisting it.

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.

Plinth Metaprogramming: bind each List element to an indexed name.
3 participants