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

[Builtins] Add the 'dropList' builtin #6468

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

effectfully
Copy link
Contributor

This experiment adds the dropList builtin so that folks can play with it. Not intended for merging.

@effectfully effectfully added Do not merge Builtins EXPERIMENT Experiments that we probably don't want to merge labels Sep 11, 2024
@effectfully effectfully force-pushed the effectfully/builtins/add-dropList branch from 017e9d4 to df4dea7 Compare September 11, 2024 18:10
@effectfully effectfully added the No Changelog Required Add this to skip the Changelog Check label Sep 11, 2024
@effectfully effectfully force-pushed the effectfully/builtins/add-dropList branch from df4dea7 to 7be8e1f Compare September 14, 2024 00:43
@effectfully effectfully force-pushed the effectfully/builtins/add-dropList branch from 7be8e1f to e22a57b Compare September 14, 2024 03:40
@effectfully effectfully mentioned this pull request Oct 23, 2024
3 tasks
@effectfully effectfully self-assigned this Oct 29, 2024
Copy link
Contributor

@kwxm kwxm left a comment

Choose a reason for hiding this comment

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

I've added some comments based on a quick look. I may have another look later.

@@ -1557,6 +1558,18 @@ instance uni ~ DefaultUni => ToBuiltinMeaning uni DefaultFun where
nullListDenotation
(runCostingFunOneArgument . paramNullList)

toBuiltinMeaning _semvar DropList =
let dropListDenotation :: Int -> SomeConstant uni [a] -> BuiltinResult (Opaque val [a])
Copy link
Contributor

Choose a reason for hiding this comment

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

The time taken for this will probably be linear in the value (not the size!) of the first argument. That'll mean susing some newtype wrapper, like this . We already have IntegerCostedLiterally, but this has an Int so that may need another wrapper.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

^ @ramsay-t FYI

but this has an Int so that may need another wrapper.

Actually, why did I even make it Int, what's the point? Looks like a thinko.

@@ -82,6 +82,7 @@ module PlutusTx.Builtins (
, headMaybe
, BI.head
, BI.tail
, BI.drop
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this also go in PlutusTx.Prelude? I seem to remember that the contents of that file are kind of random though.

@@ -408,6 +409,10 @@ chooseList :: BuiltinList a -> b -> b -> b
chooseList (BuiltinList []) b1 _ = b1
chooseList (BuiltinList (_:_)) _ b2 = b2

{-# OPAQUE drop #-}
drop :: Integer -> BuiltinList a -> BuiltinList a
Copy link
Contributor

@kwxm kwxm Oct 30, 2024

Choose a reason for hiding this comment

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

Why not dropList? So that it just replaces the Haskell version with minimal effort from the user?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For consistency, we also have head (and not headList) and tail (and not tailList) in this file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Builtins Do not merge EXPERIMENT Experiments that we probably don't want to merge No Changelog Required Add this to skip the Changelog Check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants