diff --git a/plutus-core/plutus-core/src/PlutusCore/Default/Builtins.hs b/plutus-core/plutus-core/src/PlutusCore/Default/Builtins.hs index ff2a4164a31..adda9df0b03 100644 --- a/plutus-core/plutus-core/src/PlutusCore/Default/Builtins.hs +++ b/plutus-core/plutus-core/src/PlutusCore/Default/Builtins.hs @@ -103,6 +103,7 @@ data DefaultFun | HeadList | TailList | NullList + | DropList -- Data -- See Note [Pattern matching on built-in types]. -- It is convenient to have a "choosing" function for a data type that has more than two @@ -1543,6 +1544,18 @@ instance uni ~ DefaultUni => ToBuiltinMeaning uni DefaultFun where nullListDenotation (runCostingFunOneArgument . paramNullList) + toBuiltinMeaning _semvar DropList = + let dropListDenotation :: Int -> SomeConstant uni [a] -> BuiltinResult (Opaque val [a]) + dropListDenotation i (SomeConstant (Some (ValueOf uniListA xs))) = do + -- See Note [Operational vs structural errors within builtins]. + case uniListA of + DefaultUniList _ -> pure . fromValueOf uniListA $ drop i xs + _ -> throwing _StructuralUnliftingError "Expected a list but got something else" + {-# INLINE dropListDenotation #-} + in makeBuiltinMeaning + dropListDenotation + (runCostingFunTwoArguments . unimplementedCostingFun) + -- Data toBuiltinMeaning _semvar ChooseData = let chooseDataDenotation :: Data -> a -> a -> a -> a -> a -> a @@ -2144,6 +2157,8 @@ instance Flat DefaultFun where ExpModInteger -> 87 + DropList -> 88 + decode = go =<< decodeBuiltin where go 0 = pure AddInteger go 1 = pure SubtractInteger @@ -2233,6 +2248,7 @@ instance Flat DefaultFun where go 85 = pure FindFirstSetBit go 86 = pure Ripemd_160 go 87 = pure ExpModInteger + go 88 = pure DropList go t = fail $ "Failed to decode builtin tag, got: " ++ show t size _ n = n + builtinTagWidth diff --git a/plutus-core/plutus-core/test/TypeSynthesis/Golden/DefaultFun/DropList.plc.golden b/plutus-core/plutus-core/test/TypeSynthesis/Golden/DefaultFun/DropList.plc.golden new file mode 100644 index 00000000000..bca92b3691c --- /dev/null +++ b/plutus-core/plutus-core/test/TypeSynthesis/Golden/DefaultFun/DropList.plc.golden @@ -0,0 +1 @@ +all a. integer -> list a -> list a \ No newline at end of file diff --git a/plutus-core/plutus-ir/src/PlutusIR/Transform/RewriteRules/CommuteFnWithConst.hs b/plutus-core/plutus-ir/src/PlutusIR/Transform/RewriteRules/CommuteFnWithConst.hs index c35a22ad479..e566ca80f3d 100644 --- a/plutus-core/plutus-ir/src/PlutusIR/Transform/RewriteRules/CommuteFnWithConst.hs +++ b/plutus-core/plutus-ir/src/PlutusIR/Transform/RewriteRules/CommuteFnWithConst.hs @@ -144,3 +144,4 @@ isCommutative = \case CountSetBits -> False FindFirstSetBit -> False ExpModInteger -> False + DropList -> False diff --git a/plutus-tx-plugin/src/PlutusTx/Compiler/Builtins.hs b/plutus-tx-plugin/src/PlutusTx/Compiler/Builtins.hs index e6db60bed88..1c4a632f07e 100644 --- a/plutus-tx-plugin/src/PlutusTx/Compiler/Builtins.hs +++ b/plutus-tx-plugin/src/PlutusTx/Compiler/Builtins.hs @@ -233,6 +233,7 @@ builtinNames = [ , 'Builtins.mkNilData , 'Builtins.mkNilPairData , 'Builtins.mkCons + , 'Builtins.drop , ''Builtins.BuiltinData , 'Builtins.chooseData @@ -410,6 +411,7 @@ defineBuiltinTerms = do PLC.MkNilData -> defineBuiltinInl 'Builtins.mkNilData PLC.MkNilPairData -> defineBuiltinInl 'Builtins.mkNilPairData PLC.MkCons -> defineBuiltinInl 'Builtins.mkCons + PLC.DropList -> defineBuiltinInl 'Builtins.drop -- Data PLC.ChooseData -> defineBuiltinInl 'Builtins.chooseData diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt.pir.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt.pir.golden index d77b76dda76..98434fc3b1b 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt.pir.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt.pir.golden @@ -13,9 +13,9 @@ program in trace {unit -> integer} - "entering addInteger-131" + "entering addInteger-133" (\(thunk : unit) -> - trace {integer} "exiting addInteger-131" (addInteger x y)) + trace {integer} "exiting addInteger-133" (addInteger x y)) () ~addInt : integer -> integer -> integer = \(x : integer) -> @@ -24,9 +24,9 @@ program in trace {unit -> integer -> integer} - "entering addInt-128" + "entering addInt-130" (\(thunk : unit) -> - trace {integer -> integer} "exiting addInt-128" (addInteger x)) + trace {integer -> integer} "exiting addInt-130" (addInteger x)) () in addInt) \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt3.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt3.eval.golden index 66b848fa868..a66194d84b0 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt3.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt3.eval.golden @@ -1 +1 @@ -[entering addInt-128, exiting addInt-128] \ No newline at end of file +[entering addInt-130, exiting addInt-130] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch1.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch1.eval.golden index 19f028f27ca..5a06f466d93 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch1.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch1.eval.golden @@ -1,6 +1,6 @@ -[ entering runIdentity-131 -, exiting runIdentity-131 -, entering newtypeFunction-139 -, exiting newtypeFunction-139 -, entering `$fFoldableIdentity`-133 -, exiting `$fFoldableIdentity`-133 ] \ No newline at end of file +[ entering runIdentity-133 +, exiting runIdentity-133 +, entering newtypeFunction-141 +, exiting newtypeFunction-141 +, entering `$fFoldableIdentity`-135 +, exiting `$fFoldableIdentity`-135 ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch2.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch2.eval.golden index 866a739a4c8..fb5d1b04c86 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch2.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch2.eval.golden @@ -1 +1 @@ -[entering obscuredFunction-129, exiting obscuredFunction-129] \ No newline at end of file +[entering obscuredFunction-131, exiting obscuredFunction-131] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fact4.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fact4.eval.golden index 33f55c5979c..0a3a7b1d8bd 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fact4.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fact4.eval.golden @@ -1,36 +1,36 @@ -[ entering fact-128 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, entering subtractInteger-152 -, exiting subtractInteger-152 -, entering fact-128 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, entering subtractInteger-152 -, exiting subtractInteger-152 -, entering fact-128 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, entering subtractInteger-152 -, exiting subtractInteger-152 -, entering fact-128 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, entering subtractInteger-152 -, exiting subtractInteger-152 -, entering fact-128 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, exiting fact-128 -, entering multiplyInteger-146 -, exiting multiplyInteger-146 -, exiting fact-128 -, entering multiplyInteger-146 -, exiting multiplyInteger-146 -, exiting fact-128 -, entering multiplyInteger-146 -, exiting multiplyInteger-146 -, exiting fact-128 -, entering multiplyInteger-146 -, exiting multiplyInteger-146 -, exiting fact-128 ] \ No newline at end of file +[ entering fact-130 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, entering subtractInteger-154 +, exiting subtractInteger-154 +, entering fact-130 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, entering subtractInteger-154 +, exiting subtractInteger-154 +, entering fact-130 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, entering subtractInteger-154 +, exiting subtractInteger-154 +, entering fact-130 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, entering subtractInteger-154 +, exiting subtractInteger-154 +, entering fact-130 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, exiting fact-130 +, entering multiplyInteger-148 +, exiting multiplyInteger-148 +, exiting fact-130 +, entering multiplyInteger-148 +, exiting multiplyInteger-148 +, exiting fact-130 +, entering multiplyInteger-148 +, exiting multiplyInteger-148 +, exiting fact-130 +, entering multiplyInteger-148 +, exiting multiplyInteger-148 +, exiting fact-130 ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib.pir.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib.pir.golden index c53e980e4c4..e7cac392134 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib.pir.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib.pir.golden @@ -13,9 +13,9 @@ program in trace {unit -> integer} - "entering addInteger-150" + "entering addInteger-152" (\(thunk : unit) -> - trace {integer} "exiting addInteger-150" (addInteger x y)) + trace {integer} "exiting addInteger-152" (addInteger x y)) () data Bool | Bool_match where True : Bool @@ -33,11 +33,11 @@ program in trace {unit -> Bool} - "entering equalsInteger-135" + "entering equalsInteger-137" (\(thunk : unit) -> trace {Bool} - "exiting equalsInteger-135" + "exiting equalsInteger-137" (let !b : bool = equalsInteger x y in @@ -55,11 +55,11 @@ program in trace {unit -> integer} - "entering subtractInteger-156" + "entering subtractInteger-158" (\(thunk : unit) -> trace {integer} - "exiting subtractInteger-156" + "exiting subtractInteger-158" (subtractInteger x y)) () in @@ -71,11 +71,11 @@ program in trace {unit -> integer} - "entering fib-128" + "entering fib-130" (\(thunk : unit) -> trace {integer} - "exiting fib-128" + "exiting fib-130" (Bool_match (equalsInteger n 0) {all dead. integer} diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib4.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib4.eval.golden index 693c65f8713..8dfeaf06f83 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib4.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib4.eval.golden @@ -1,74 +1,74 @@ -[ entering fib-128 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, entering subtractInteger-156 -, exiting subtractInteger-156 -, entering fib-128 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, entering subtractInteger-156 -, exiting subtractInteger-156 -, entering fib-128 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, entering subtractInteger-156 -, exiting subtractInteger-156 -, entering fib-128 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, exiting fib-128 -, entering subtractInteger-156 -, exiting subtractInteger-156 -, entering fib-128 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, exiting fib-128 -, entering addInteger-150 -, exiting addInteger-150 -, exiting fib-128 -, entering subtractInteger-156 -, exiting subtractInteger-156 -, entering fib-128 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, exiting fib-128 -, entering addInteger-150 -, exiting addInteger-150 -, exiting fib-128 -, entering subtractInteger-156 -, exiting subtractInteger-156 -, entering fib-128 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, entering subtractInteger-156 -, exiting subtractInteger-156 -, entering fib-128 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, exiting fib-128 -, entering subtractInteger-156 -, exiting subtractInteger-156 -, entering fib-128 -, entering equalsInteger-135 -, exiting equalsInteger-135 -, exiting fib-128 -, entering addInteger-150 -, exiting addInteger-150 -, exiting fib-128 -, entering addInteger-150 -, exiting addInteger-150 -, exiting fib-128 ] \ No newline at end of file +[ entering fib-130 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, entering subtractInteger-158 +, exiting subtractInteger-158 +, entering fib-130 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, entering subtractInteger-158 +, exiting subtractInteger-158 +, entering fib-130 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, entering subtractInteger-158 +, exiting subtractInteger-158 +, entering fib-130 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, exiting fib-130 +, entering subtractInteger-158 +, exiting subtractInteger-158 +, entering fib-130 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, exiting fib-130 +, entering addInteger-152 +, exiting addInteger-152 +, exiting fib-130 +, entering subtractInteger-158 +, exiting subtractInteger-158 +, entering fib-130 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, exiting fib-130 +, entering addInteger-152 +, exiting addInteger-152 +, exiting fib-130 +, entering subtractInteger-158 +, exiting subtractInteger-158 +, entering fib-130 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, entering subtractInteger-158 +, exiting subtractInteger-158 +, entering fib-130 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, exiting fib-130 +, entering subtractInteger-158 +, exiting subtractInteger-158 +, entering fib-130 +, entering equalsInteger-137 +, exiting equalsInteger-137 +, exiting fib-130 +, entering addInteger-152 +, exiting addInteger-152 +, exiting fib-130 +, entering addInteger-152 +, exiting addInteger-152 +, exiting fib-130 ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/id.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/id.eval.golden index 5e31f19d924..05af16bb174 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/id.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/id.eval.golden @@ -1 +1 @@ -[entering id-129, exiting id-129, entering id-129, exiting id-129] \ No newline at end of file +[entering id-131, exiting id-131, entering id-131, exiting id-131] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/idCode.pir.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/idCode.pir.golden index e8874d71960..186878b34a7 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/idCode.pir.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/idCode.pir.golden @@ -6,8 +6,8 @@ program \(x : a) -> trace {unit -> a} - "entering id-129" - (\(thunk : unit) -> trace {a} "exiting id-129" x) + "entering id-131" + (\(thunk : unit) -> trace {a} "exiting id-131" x) () in id {integer} (id {integer} 1)) \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFun.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFun.eval.golden index e598b91086d..52a743e3dd9 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFun.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFun.eval.golden @@ -1,10 +1,10 @@ -[ entering f-140 -, entering addInteger-134 -, exiting addInteger-134 -, exiting f-140 -, entering f-140 -, entering addInteger-134 -, exiting addInteger-134 -, exiting f-140 -, entering addInteger-134 -, exiting addInteger-134 ] \ No newline at end of file +[ entering f-142 +, entering addInteger-136 +, exiting addInteger-136 +, exiting f-142 +, entering f-142 +, entering addInteger-136 +, exiting addInteger-136 +, exiting f-142 +, entering addInteger-136 +, exiting addInteger-136 ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFunMoreArg.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFunMoreArg.eval.golden index 42995b25478..82a64991de7 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFunMoreArg.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFunMoreArg.eval.golden @@ -1,12 +1,12 @@ -[ entering f-142 -, entering addInteger-136 -, exiting addInteger-136 -, exiting f-142 -, entering f-142 -, entering addInteger-136 -, exiting addInteger-136 -, exiting f-142 -, entering addInteger-136 -, exiting addInteger-136 -, entering multiplyInteger-144 -, exiting multiplyInteger-144 ] \ No newline at end of file +[ entering f-144 +, entering addInteger-138 +, exiting addInteger-138 +, exiting f-144 +, entering f-144 +, entering addInteger-138 +, exiting addInteger-138 +, exiting f-144 +, entering addInteger-138 +, exiting addInteger-138 +, entering multiplyInteger-146 +, exiting multiplyInteger-146 ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letRecInFun.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letRecInFun.eval.golden index dce946b6315..3adff1bc499 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letRecInFun.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letRecInFun.eval.golden @@ -1,28 +1,28 @@ -[ entering f-130 -, entering equalsInteger-137 -, exiting equalsInteger-137 -, entering subtractInteger-154 -, exiting subtractInteger-154 -, entering f-130 -, entering equalsInteger-137 -, exiting equalsInteger-137 -, entering subtractInteger-154 -, exiting subtractInteger-154 -, entering f-130 -, entering equalsInteger-137 -, exiting equalsInteger-137 -, entering subtractInteger-154 -, exiting subtractInteger-154 -, entering f-130 -, entering equalsInteger-137 -, exiting equalsInteger-137 -, exiting f-130 -, entering addInteger-148 -, exiting addInteger-148 -, exiting f-130 -, entering addInteger-148 -, exiting addInteger-148 -, exiting f-130 -, entering addInteger-148 -, exiting addInteger-148 -, exiting f-130 ] \ No newline at end of file +[ entering f-132 +, entering equalsInteger-139 +, exiting equalsInteger-139 +, entering subtractInteger-156 +, exiting subtractInteger-156 +, entering f-132 +, entering equalsInteger-139 +, exiting equalsInteger-139 +, entering subtractInteger-156 +, exiting subtractInteger-156 +, entering f-132 +, entering equalsInteger-139 +, exiting equalsInteger-139 +, entering subtractInteger-156 +, exiting subtractInteger-156 +, entering f-132 +, entering equalsInteger-139 +, exiting equalsInteger-139 +, exiting f-132 +, entering addInteger-150 +, exiting addInteger-150 +, exiting f-132 +, entering addInteger-150 +, exiting addInteger-150 +, exiting f-132 +, entering addInteger-150 +, exiting addInteger-150 +, exiting f-132 ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/swap.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/swap.eval.golden index ea3312abd43..d5362e55082 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/swap.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/swap.eval.golden @@ -1 +1 @@ -[entering swap-135, exiting swap-135] \ No newline at end of file +[entering swap-137, exiting swap-137] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/typeclass.eval.golden b/plutus-tx-plugin/test/Plugin/Profiling/9.6/typeclass.eval.golden index 5698abc5173..1a57d495358 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/typeclass.eval.golden +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/typeclass.eval.golden @@ -1,12 +1,12 @@ -[ entering useTypeclass-137 -, entering methodA-151 -, exiting methodA-151 -, entering addInteger-144 -, exiting addInteger-144 -, entering methodB-162 -, exiting methodB-162 -, entering subtractInteger-174 -, exiting subtractInteger-174 -, entering addInteger-144 -, exiting addInteger-144 -, exiting useTypeclass-137 ] \ No newline at end of file +[ entering useTypeclass-139 +, entering methodA-153 +, exiting methodA-153 +, entering addInteger-146 +, exiting addInteger-146 +, entering methodB-164 +, exiting methodB-164 +, entering subtractInteger-176 +, exiting subtractInteger-176 +, entering addInteger-146 +, exiting addInteger-146 +, exiting useTypeclass-139 ] \ No newline at end of file diff --git a/plutus-tx/src/PlutusTx/Builtins.hs b/plutus-tx/src/PlutusTx/Builtins.hs index 78a39fe09e2..a279a46fdf4 100644 --- a/plutus-tx/src/PlutusTx/Builtins.hs +++ b/plutus-tx/src/PlutusTx/Builtins.hs @@ -78,6 +78,7 @@ module PlutusTx.Builtins ( , headMaybe , BI.head , BI.tail + , BI.drop , uncons , unsafeUncons -- * Tracing diff --git a/plutus-tx/src/PlutusTx/Builtins/Internal.hs b/plutus-tx/src/PlutusTx/Builtins/Internal.hs index e817ea6a552..eff1f1ed078 100644 --- a/plutus-tx/src/PlutusTx/Builtins/Internal.hs +++ b/plutus-tx/src/PlutusTx/Builtins/Internal.hs @@ -29,6 +29,7 @@ import Data.Data (Data) import Data.Foldable qualified as Foldable import Data.Hashable (Hashable (..)) import Data.Kind (Type) +import Data.List qualified as Haskell import Data.Text as Text (Text, empty) import Data.Text.Encoding as Text (decodeUtf8, encodeUtf8) import GHC.Generics (Generic) @@ -408,6 +409,10 @@ chooseList :: BuiltinList a -> b -> b -> b chooseList (BuiltinList []) b1 _ = b1 chooseList (BuiltinList (_:_)) _ b2 = b2 +{-# NOINLINE drop #-} +drop :: Integer -> BuiltinList a -> BuiltinList a +drop i (BuiltinList xs) = BuiltinList (Haskell.genericDrop i xs) + {-# NOINLINE mkNilData #-} mkNilData :: BuiltinUnit -> BuiltinList BuiltinData mkNilData _ = BuiltinList []