forked from IntersectMBO/plutus
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid evaluating
nilCase
strictly in matchList
, and rename the or…
…iginal `matchList` to `matchList'` (IntersectMBO#5901)
- Loading branch information
Showing
13 changed files
with
161 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
plutus-tx-plugin/test/Budget/9.6/builtinListIndexing.budget.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
({cpu: 11720376 | ||
| mem: 32730}) |
1 change: 1 addition & 0 deletions
1
plutus-tx-plugin/test/Budget/9.6/builtinListIndexing.eval.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(con data (I 6)) |
32 changes: 32 additions & 0 deletions
32
plutus-tx-plugin/test/Budget/9.6/builtinListIndexing.pir.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
let | ||
data Unit | Unit_match where | ||
Unit : Unit | ||
in | ||
letrec | ||
!go : list data -> integer -> data | ||
= \(xs : list data) (i : integer) -> | ||
chooseList | ||
{data} | ||
{Unit -> Unit -> data} | ||
xs | ||
(\(ds : Unit) -> error {Unit -> data}) | ||
(\(ds : Unit) (ds : Unit) -> | ||
let | ||
!hd : data = headList {data} xs | ||
!tl : list data = tailList {data} xs | ||
in | ||
ifThenElse | ||
{all dead. data} | ||
(equalsInteger 0 i) | ||
(/\dead -> hd) | ||
(/\dead -> go tl (subtractInteger i 1)) | ||
{all dead. dead}) | ||
Unit | ||
Unit | ||
in | ||
let | ||
data Bool | Bool_match where | ||
True : Bool | ||
False : Bool | ||
in | ||
\(d : data) -> let !xs : list data = unListData d in go xs 5 |
20 changes: 20 additions & 0 deletions
20
plutus-tx-plugin/test/Budget/9.6/builtinListIndexing.uplc.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
program | ||
1.1.0 | ||
((\go d -> go (unListData d) 5) | ||
((\s -> s s) | ||
(\s xs i -> | ||
force (force chooseList) | ||
xs | ||
(\ds -> error) | ||
(\ds ds -> | ||
(\hd -> | ||
(\tl -> | ||
force | ||
(force ifThenElse | ||
(equalsInteger 0 i) | ||
(delay hd) | ||
(delay (s s tl (subtractInteger i 1))))) | ||
(force tailList xs)) | ||
(force headList xs)) | ||
(constr 0 []) | ||
(constr 0 [])))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
({cpu: 10267419 | ||
| mem: 32722}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(con data (I 6)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
letrec | ||
data (List :: * -> *) a | List_match where | ||
Nil : List a | ||
Cons : a -> List a -> List a | ||
in | ||
letrec | ||
!go : integer -> List data -> data | ||
= \(ds : integer) (ds : List data) -> | ||
List_match | ||
{data} | ||
ds | ||
{all dead. data} | ||
(/\dead -> error {data}) | ||
(\(x : data) (xs : List data) -> | ||
/\dead -> | ||
ifThenElse | ||
{all dead. data} | ||
(equalsInteger 0 ds) | ||
(/\dead -> x) | ||
(/\dead -> go (subtractInteger ds 1) xs) | ||
{all dead. dead}) | ||
{all dead. dead} | ||
in | ||
let | ||
data Bool | Bool_match where | ||
True : Bool | ||
False : Bool | ||
data Unit | Unit_match where | ||
Unit : Unit | ||
in | ||
\(xs : List data) -> go 5 xs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
program | ||
1.1.0 | ||
((\go xs -> go 5 xs) | ||
((\s -> s s) | ||
(\s ds ds -> | ||
force | ||
(case | ||
ds | ||
[ (delay error) | ||
, (\x xs -> | ||
delay | ||
(force | ||
(force ifThenElse | ||
(equalsInteger 0 ds) | ||
(delay x) | ||
(delay | ||
((\x -> s s x) | ||
(subtractInteger ds 1) | ||
xs))))) ])))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
plutus-tx/changelog.d/20240509_114920_unsafeFixIO_index_budget.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
### Changed | ||
|
||
- Renamed `PlutusTx.Builtins.matchList` to `matchList'`. The new `matchList` takes | ||
an argument of type `() -> r` for the `nil` case, ensuring that the nil case | ||
isn't evaluated if the list is non-empty. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters