-
Notifications
You must be signed in to change notification settings - Fork 479
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
base: master
Are you sure you want to change the base?
Conversation
017e9d4
to
df4dea7
Compare
df4dea7
to
7be8e1f
Compare
…to effectfully/builtins/add-dropList
7be8e1f
to
e22a57b
Compare
…to effectfully/builtins/add-dropList
16db02d
to
41ea9b6
Compare
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.
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]) |
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.
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.
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.
^ @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 |
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 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 |
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.
Why not dropList
? So that it just replaces the Haskell version with minimal effort from the user?
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.
For consistency, we also have head
(and not headList
) and tail
(and not tailList
) in this file.
This experiment adds the
dropList
builtin so that folks can play with it. Not intended for merging.