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 Map backed by Data #5927

Merged
merged 44 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c03986f
Add AssocList backed by Data
ana-pantilie Apr 29, 2024
0fcaac8
Fix build
ana-pantilie Apr 29, 2024
360474d
Fix AssocList union
ana-pantilie Apr 29, 2024
a730d6b
Add unionWith property test
ana-pantilie Apr 29, 2024
0d75e65
Clean-up
ana-pantilie Apr 29, 2024
ec6bccd
Fix performance bug
ana-pantilie Apr 29, 2024
634bea6
Add golden files for new tests
ana-pantilie Apr 29, 2024
857f418
Add documentation to AssocList
ana-pantilie Apr 29, 2024
8e620e5
Add docs to tests
ana-pantilie Apr 29, 2024
721d82d
Add data encoding test
ana-pantilie Apr 29, 2024
0f1d945
Address some review comments
ana-pantilie Apr 30, 2024
7dbd045
Rename AssocList to AssocMap
ana-pantilie May 7, 2024
0b51d91
Make Map newtype over BuiltinList Pair
ana-pantilie May 7, 2024
75edbf9
Fix union implementation
ana-pantilie May 8, 2024
cd2d843
Use BuiltinList internal functions
ana-pantilie May 8, 2024
4071a8a
Create internal top-level delete
ana-pantilie May 8, 2024
7d96dc4
Add union test
ana-pantilie May 8, 2024
2862dec
Add docs to integration tests
ana-pantilie May 8, 2024
1f7f634
Try naive type families
effectfully May 9, 2024
94ff0ff
Split 'Has*' into 'From*' and 'To*' again
effectfully May 10, 2024
1f0d147
Remove type families from '*Opaque'
effectfully May 10, 2024
8a02b66
Add 'ToBuiltin'
effectfully May 11, 2024
669e25f
Add 'TestInstances'
effectfully May 11, 2024
bb18d98
Make it work for GHC-8.10
effectfully May 11, 2024
0ec5c85
Polishing
effectfully May 12, 2024
173ee90
Improve docs
effectfully May 13, 2024
6e329d6
Polishing
effectfully May 13, 2024
ee05a90
Merge remote-tracking branch 'origin/master' into ana/data-assoclist
ana-pantilie May 13, 2024
29f0b1a
Address comments
effectfully May 14, 2024
f98841e
Fix compilation errors in AssocMap
ana-pantilie May 14, 2024
38270be
Add utils from bench package to plutus-tx-plugin tests
ana-pantilie May 14, 2024
a033dc0
Run first PlutusTx property test
ana-pantilie May 14, 2024
bc462b7
WIP: add makeLift to new Map type
ana-pantilie May 14, 2024
105d51c
Merge remote-tracking branch 'origin/effectfully/builtins/split-FromB…
ana-pantilie May 14, 2024
b2e34e4
Add first fully working plutus tx property test
ana-pantilie May 14, 2024
2ae4bf1
Merge remote-tracking branch 'origin/master' into ana/data-assoclist
ana-pantilie May 16, 2024
6f77819
Fix issue with insert propety test
ana-pantilie May 16, 2024
c57c9b7
Run all tests with PlutusTx
ana-pantilie May 16, 2024
678992d
Add changelog
ana-pantilie May 16, 2024
8cda32b
Fix test module warning
ana-pantilie May 21, 2024
393162c
Fix isData instance for These
ana-pantilie May 21, 2024
361cba3
Fix delete implementation
ana-pantilie May 21, 2024
72334a5
Fix redundancy
ana-pantilie May 21, 2024
c5c85ed
Address other review comments
ana-pantilie May 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve docs
  • Loading branch information
effectfully committed May 13, 2024
commit 173ee907e1fd0558fd89aa9804a91a72a99fd723
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Changed

- Split `PlutusTx.Builtins.Class` into `PlutusTx.Builtins.HasBuiltin` and `PlutusTx.Builtins.HasOpaque` in #5971:
+ Split 'FromBuiltin' into 'HasFromBuiltin' and 'HasFromOpaque'
+ Split 'ToBuiltin' into 'HasToBuiltin' and 'HasToOpaque'
171 changes: 0 additions & 171 deletions plutus-tx/src/PlutusTx/Builtins/Class.hs

This file was deleted.

25 changes: 4 additions & 21 deletions plutus-tx/src/PlutusTx/Builtins/HasBuiltin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ import Data.ByteString (ByteString)
import Data.Kind qualified as GHC
import Data.Text (Text)

-- | A class for converting values of Haskell-defined built-in types to their Plutus Tx
-- counterparts.
type HasToBuiltin :: GHC.Type -> GHC.Constraint
class PLC.DefaultUni `PLC.Contains` a => HasToBuiltin a where
type ToBuiltin a
toBuiltin :: a -> ToBuiltin a

-- | A class for converting values of Plutus Tx built-in types to their Haskell-defined
-- counterparts.
type HasFromBuiltin :: GHC.Type -> GHC.Constraint
class HasToBuiltin (FromBuiltin arep) => HasFromBuiltin arep where
type FromBuiltin arep
Expand Down Expand Up @@ -105,24 +109,3 @@ instance HasToBuiltin BLS12_381.Pairing.MlResult where
instance HasFromBuiltin BuiltinBLS12_381_MlResult where
type FromBuiltin BuiltinBLS12_381_MlResult = BLS12_381.Pairing.MlResult
fromBuiltin (BuiltinBLS12_381_MlResult a) = a

{- Note [noinline hack]
For some functions we have two conflicting desires:
- We want to have the unfolding available for the plugin.
- We don't want the function to *actually* get inlined before the plugin runs, since we rely
on being able to see the original function for some reason.

'INLINABLE' achieves the first, but may cause the function to be inlined too soon.

We can solve this at specific call sites by using the 'noinline' magic function from
GHC. This stops GHC from inlining it. As a bonus, it also won't be inlined if
that function is compiled later into the body of another function.

We do therefore need to handle 'noinline' in the plugin, as it itself does not have
an unfolding.

Another annoying quirk: even if you have 'noinline'd a function call, if the body is
a single variable, it will still inline! This is the case for the obvious definition
of 'stringToBuiltinString' (since the newtype constructor vanishes), so we have to add
some obfuscation to the body to prevent it inlining.
-}
Loading