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

Plutarch 1.2 #317

Merged
merged 738 commits into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from 180 commits
Commits
Show all changes
738 commits
Select commit Hold shift + click to select a range
b2b9e05
Use explicit imports
TotallyNotChase May 4, 2022
6a93287
Update CHANGELOG
TotallyNotChase May 4, 2022
dedcf33
Merge pull request #466 from Plutonomicon/some-exports
L-as May 6, 2022
0399120
Added AssocMap.singleton and Value.singleton
blamario Mar 23, 2022
03ff1c5
Added valueOf, lookup, lookupData, and pmaybe
blamario Mar 24, 2022
ac58aee
Added AssocMap.singletonData
blamario Mar 24, 2022
5e08c0f
More tests
blamario Mar 24, 2022
3141d18
Optimized lookup using precList
blamario Mar 24, 2022
98eec12
Added tests for pmaybe and pfromJust
blamario Apr 1, 2022
6f42768
Added AssocMap tests
blamario Apr 1, 2022
5837ce1
Added Value.unionWith and everything it depends on
blamario Apr 5, 2022
76a686c
Added insert & insertData
blamario Apr 7, 2022
99a4014
Added delete & deleteData
blamario Apr 7, 2022
192bbd5
Factored out the common logic of insert & delete
blamario Apr 7, 2022
2c77a22
Restored the deleted golden files
blamario Apr 7, 2022
1c506d0
Applied testing suggestions
blamario Apr 7, 2022
5df4ff0
Added PValue equality and its dependencies
blamario Apr 8, 2022
0b84e43
Fixed the merge
blamario Apr 8, 2022
4cb0ea8
Added some FFI benchmarks
blamario Apr 15, 2022
26452fc
Made fourmolu ignore the tmp/ directory
blamario Apr 18, 2022
38707e4
More benchmarks, native Plutarch vs FFI for Value operations
blamario Apr 18, 2022
814bd6f
Added Value.unionWithData
blamario Apr 18, 2022
7518cfa
Benchmarks for valueOf
blamario Apr 18, 2022
2bb4c57
Introduced AssocMap.foldAt & findWithDefault to optimize valueOf
blamario Apr 18, 2022
41e3581
Reverted a stupid kind annotation
blamario Apr 21, 2022
ad0e5b9
More tests
blamario Apr 21, 2022
2e0208e
Keep the AssocMap sorted by key data
blamario Apr 21, 2022
fd1677b
Added Value.normalize and AssocMap.filter/mapMaybe/null
blamario Apr 21, 2022
a2a5953
Switched the equality to the quicker implementation
blamario Apr 21, 2022
68bfa71
Added Semigroup instances
blamario Apr 21, 2022
9779968
Fixed tests with GHC 8.10
blamario Apr 21, 2022
afe5a92
Added goldens that were missing for some reason
blamario Apr 21, 2022
fc1ed5f
Added Monoid instances
blamario Apr 22, 2022
de3d78e
Fix for the unsused goldens CI failure
blamario Apr 22, 2022
fad3e15
Formatting
blamario Apr 22, 2022
0062b51
Added asertSorted
blamario Apr 22, 2022
97a5626
assertSorted tests
blamario Apr 22, 2022
ee824e3
Split the dev/nodev Value API goldens
blamario Apr 25, 2022
0343b2f
Added Value.normalize tests
blamario Apr 25, 2022
01156f6
Added Value.singletonData
blamario Apr 26, 2022
f9f97ac
Added a nominal ValueState parameter to PValue
blamario Apr 27, 2022
cdcdca5
p all over the API
blamario Apr 27, 2022
4b18c46
Added the Positive values
blamario Apr 27, 2022
3430364
No need to resort the currency symbols in passertPositive
blamario Apr 27, 2022
6dd6c37
Rebase fixes
blamario May 3, 2022
5969e06
Removed pmaybe, peither, pmapEitherWithKey[Data] of dubious efficiency
blamario May 3, 2022
294609f
Removed a (..) import
blamario May 6, 2022
a3c2ae9
Narrowed the type of fee and UTxO value to Positive
blamario May 6, 2022
8c44bde
Formatting
blamario May 6, 2022
61b485a
Generalized the return type of pforgetPositive
blamario May 6, 2022
f92383f
Added a warning to UTxO value field
blamario May 6, 2022
f04107c
Removed the kind signatures off of (s :: S) in use sites
blamario May 6, 2022
b62487d
Removed extraneous golden outputs
blamario May 6, 2022
ae4cc22
No Haddock allowed in a type-level list
blamario May 6, 2022
cfd0e37
Inlined the Rank2.TH instances
blamario May 6, 2022
874946e
Added plet y $ \y ->
blamario May 6, 2022
889a41f
Update emanote (to get rid of lint-utils)
srid May 9, 2022
f49ab79
Composable smart names and improvements
TotallyNotChase May 9, 2022
fa69cc3
Pretty if/then/else
TotallyNotChase May 9, 2022
cbb1b0f
fix `pfindOwnInput`
TotallyNotChase May 11, 2022
5e45877
Merge pull request #469 from Plutonomicon/findownipn-fix
L-as May 11, 2022
6cd074c
Merge pull request #467 from Plutonomicon/srid/lint-utils-fix
L-as May 11, 2022
96e83e9
Fix some typos in documentation
TotallyNotChase May 12, 2022
007643d
Clarify `PLift` laws
TotallyNotChase May 12, 2022
d62c38b
Add `PIsData` constraint to `PConstantData` and `PLiftData`
TotallyNotChase May 12, 2022
ae2059f
Merge pull request #470 from Plutonomicon/cleanup
L-as May 12, 2022
4dc31f4
Merge branch 'staging' into mario/value-api
blamario May 12, 2022
683c653
Shortened the *Guarantees names and moved KeyGuarantees into AssocMap
blamario May 12, 2022
874d3e7
Added a KeyGuarantees parameter to PMap
blamario May 12, 2022
fffe864
Added pmap and PlutusTx.Group instances
blamario May 12, 2022
04f90d5
Fixed the type roles
blamario May 13, 2022
1594234
Added -Wredundant-constraints and acted on the warnings
blamario May 13, 2022
9f6326d
Update dependencies
L-as Apr 17, 2022
41caa60
Fix `Plutarch.Lift`
L-as Apr 18, 2022
14432b5
test: getSpecDescriptionPath now returns list in different order
srid Apr 18, 2022
be9c8c0
Fix incorrect let binding pretty print
TotallyNotChase May 16, 2022
ff3e123
Update dependencies again, use `applyPlutarchDep`, and stop using for…
L-as Apr 19, 2022
0df7165
Removed -Wredundant-constraints, too many false positives
blamario May 16, 2022
6de73b5
Merge branch 'staging' into rational-experiment
TotallyNotChase May 16, 2022
52476c4
Rename `pnonZero'` -> `ptryNonZero`
TotallyNotChase May 16, 2022
b07d97a
Deduplicate `Flip`
TotallyNotChase May 16, 2022
88916a0
`PTryFrom` instances for `PNonZero`
TotallyNotChase May 16, 2022
0ea3b7c
Unexport `PRational` constructor...
TotallyNotChase May 17, 2022
3ca3ef4
`TryFrom` instance for `PRational` and cleanup
TotallyNotChase May 17, 2022
2f66f92
`TryFrom` tests for `PRational`
TotallyNotChase May 17, 2022
33aceff
Actually run `TryFromSpec` tests
TotallyNotChase May 17, 2022
219eb47
Amend `pconstant` law
TotallyNotChase May 17, 2022
ecad1cb
Allow the PTxInfo.mint field to contain zero Ada
blamario May 18, 2022
0baae53
Use a stateful monad stack for pretty printing
TotallyNotChase May 24, 2022
e1f237b
Interval utils
May 28, 2022
e527218
`nix flake update`
L-as May 30, 2022
7fb9395
Merge pull request #396 from Plutonomicon/mario/value-api
L-as May 30, 2022
d9691f1
use `haskell-nix-extra-hackage`
L-as May 30, 2022
8a93ac0
replace haskell.nix fourmolu with nixpkgs fourmolu
MangoIV May 31, 2022
17cc393
Update stuff
L-as May 31, 2022
4d3b7a4
Update Nixpkgs
L-as May 31, 2022
7340706
add link in guide (README -> PTryFrom )
May 31, 2022
382791d
Ada-related functionality
blamario May 31, 2022
f81954e
A slight optimization most of the time
blamario May 31, 2022
5df0fad
Formatting
blamario May 31, 2022
8b470bd
Fixed a typo
blamario May 31, 2022
da570fb
Always use cabalProjectLocal
L-as May 31, 2022
ff35eaa
Replaced FFI.foreignImport with pconstant
blamario May 31, 2022
978433f
Use ghc923 and re-enable HLS
L-as Jun 1, 2022
42def00
Use nixpkgs-latest's lib
L-as Jun 1, 2022
974373a
Fix HLS
L-as Jun 1, 2022
a7da898
./bin/format
L-as Jun 1, 2022
7e0806b
add `PTryFrom` hyperlink to `Typeclasses.md`
Jun 1, 2022
df975a4
Disable unused golden checking temporarily
L-as Jun 1, 2022
34aaec7
Add remaining hyperlinks
TotallyNotChase Jun 1, 2022
9796868
Merge #475
L-as Jun 1, 2022
be1f0b0
Merge pull request #476 from peter-mlabs/patch-4
TotallyNotChase Jun 1, 2022
eb40218
Fix issue with fourmolu
L-as Jun 1, 2022
af7fbcb
Merge staging
L-as Jun 1, 2022
44ddd19
Merge pull request #477 from Plutonomicon/mario/value-ada
L-as Jun 1, 2022
6a2ae09
Update goldens
L-as Jun 1, 2022
6f7fc09
Merge branch 'staging' of github.com:Plutonomicon/plutarch into las/u…
L-as Jun 1, 2022
9da025c
Fix tests
L-as Jun 1, 2022
dc75fa3
Merge pull request #443 from Plutonomicon/las/update
L-as Jun 1, 2022
144ccad
Merge branch 'staging' into tryfrom-tests
L-as Jun 1, 2022
e7ef565
Merge pull request #471 from Plutonomicon/tryfrom-tests
L-as Jun 1, 2022
803108d
Thread hard-coded monad through Term
L-as Jun 1, 2022
5f4ea0d
Make Term monadic, remove CPP, and Plutarch.Rec (sorry)
L-as Jun 2, 2022
d7a040b
Add `evalScriptHuge` and use it in `plift'`
L-as Jun 3, 2022
6d47f7d
Deprecate `PCon` and `PMatch`
L-as Jun 3, 2022
7117eef
Merge pull request #479 from Plutonomicon/las/monadic
L-as Jun 3, 2022
db7baab
Simplify module structure by not re-exporting from `Plutarch.Internal…
L-as Jun 3, 2022
006da12
Make tests work again
L-as Jun 3, 2022
d779942
Add `PForall`
L-as Jun 3, 2022
e8fe502
adjusted the docs to work with current api
MangoIV Jun 8, 2022
dca9e65
Merge pull request #480 from Plutonomicon/mangoiv/run-guide
L-as Jun 9, 2022
436680b
Update Run.md
MangoIV Jun 11, 2022
a9bd6f2
Merge pull request #481 from Plutonomicon/mangoiv/fix-docs-mistake
L-as Jun 17, 2022
ee776e8
Rework stuff
L-as Jun 22, 2022
1142a27
Fix nix
L-as Jun 22, 2022
31ffe47
made things compile
MangoIV Jun 22, 2022
d120098
Add `PTryFrom` instance for un-dataed `PDataSum`
L-as Jun 27, 2022
e9cfbc7
Remove mistaken use of `OVERLAPPING`
L-as Jun 27, 2022
ee2798d
Try to fix `pfield`
L-as Jun 27, 2022
e4a02f6
Fix `PTryFrom` for `PDataSum`
L-as Jun 27, 2022
1362c32
Add `PlutusType` for `PString`, `PByteString`, and `PInteger`
L-as Jun 27, 2022
43ad014
Fix `PUnit` implementation
L-as Jun 27, 2022
63baa19
Make `PInner (PAsData a)` finer
L-as Jun 28, 2022
c8ad2b8
started tests fixing, minor changes
MangoIV Jun 28, 2022
752a012
Merge remote-tracking branch 'origin/las/plutustype' into mangoiv/fix…
MangoIV Jun 28, 2022
f9ced91
tests compile
MangoIV Jun 28, 2022
8acb3d9
fix tests; fix rational, regenerate goldens (bench and code)
MangoIV Jun 28, 2022
0222fc6
set -Wno-unrecognised-warning-flags
MangoIV Jun 28, 2022
a9089a5
Merge pull request #492 from Plutonomicon/mangoiv/fix-tests
L-as Jun 28, 2022
ca38fdc
revert change that broke 8.10
MangoIV Jun 28, 2022
12f4e5e
added ghc810 devShell
MangoIV Jun 28, 2022
076d3e4
fix haskell-language-server in ghc8107 devShell
MangoIV Jun 28, 2022
ff6afc6
Remove `punsafeAsClosedTerm` again
L-as Jun 29, 2022
e8be176
fixed some bugs in ghc810 and simplified some stuff but it's still br…
MangoIV Jun 29, 2022
cbc61eb
some more additions, commiting to save some other changes to another …
MangoIV Jul 2, 2022
5176221
finished adding types
MangoIV Jul 3, 2022
c4e359b
removed nonsense from V2.hs and added TODO list
MangoIV Jul 3, 2022
38fcbb3
some reexports to make working with the new types easier
MangoIV Jul 3, 2022
52491d5
Merge pull request #486 from Plutonomicon/las/plutustype
L-as Jul 4, 2022
058722a
Merge branch 'staging' into mangoiv/vasil
L-as Jul 4, 2022
079a873
fix assocmap
MangoIV Jul 4, 2022
10da8a1
Merge branch 'mangoiv/vasil' of github.com:Plutonomicon/plutarch-plut…
MangoIV Jul 4, 2022
45123c4
stop building ghc810
MangoIV Jul 4, 2022
25329db
add back ghc810 devShell because why not (hls is reliably cached and …
MangoIV Jul 4, 2022
42d848a
bump plutus version
MangoIV Jul 4, 2022
f003db8
Merge pull request #495 from Plutonomicon/mangoiv/vasil
L-as Jul 6, 2022
e753266
Merge branch 'staging' into mangoiv/remove-810-from-ci
L-as Jul 6, 2022
7e4e71c
Remove ghc 8.10 dev shell
L-as Jul 6, 2022
84acb6f
Merge pull request #499 from Plutonomicon/mangoiv/remove-810-from-ci
L-as Jul 6, 2022
c398e12
Merge branch 'staging' into rational-experiment
TotallyNotChase Jul 7, 2022
a747bcf
Tests and development flag related cleanup
TotallyNotChase Jul 7, 2022
4070f11
Add `Default` instance for `Config`
TotallyNotChase Jul 7, 2022
7ce1976
Add V2 script utils
TotallyNotChase Jul 7, 2022
ee6d21e
Fix formatting
TotallyNotChase Jul 7, 2022
9176363
Update goldens
TotallyNotChase Jul 7, 2022
ef1e083
add builtin functions
MangoIV Jul 7, 2022
b0ef8d6
Merge pull request #506 from Plutonomicon/cleanups
L-as Jul 7, 2022
acd0a4e
Merge branch 'staging' into mangoiv/vasil-builtins
L-as Jul 7, 2022
ea2166f
Merge pull request #507 from Plutonomicon/mangoiv/vasil-builtins
L-as Jul 7, 2022
28edeec
Merge branch 'staging' into rational-experiment
TotallyNotChase Jul 7, 2022
b539f9b
Build fixes and update goldens
TotallyNotChase Jul 7, 2022
a385c8d
Fix formatting
TotallyNotChase Jul 7, 2022
c657d01
fix passertSorted
MangoIV Jul 8, 2022
421b1c8
make map use data equality
MangoIV Jul 8, 2022
1001ce9
Merge branch 'staging' into mangoiv/interval-utils
MangoIV Jul 8, 2022
faba78c
Merge pull request #511 from Plutonomicon/mangoiv/fix-passertsorted
L-as Jul 8, 2022
1162618
formatting
MangoIV Jul 8, 2022
db3dc15
fix pinterval and pinterval tests, add goldens
MangoIV Jul 9, 2022
9b48ad8
fix order of type variables for hrecField and pfield and deprecate hr…
MangoIV Jul 9, 2022
2779abf
remove notion of equality for unsorted Maps
MangoIV Jul 9, 2022
0de4d09
Merge branch 'staging' into mangoiv/map-via-dataequality
L-as Jul 9, 2022
b95fd0f
Merge pull request #512 from Plutonomicon/mangoiv/map-via-dataequality
L-as Jul 9, 2022
4d34a47
Merge branch 'staging' into fix-hrecfield-pfield
L-as Jul 9, 2022
e071cc7
Merge pull request #515 from Plutonomicon/fix-hrecfield-pfield
L-as Jul 9, 2022
064e6cf
Merge branch 'staging' into pretty-scripts
TotallyNotChase Jul 10, 2022
b336549
Improve `freshVarName`
TotallyNotChase Jul 10, 2022
da5e7db
General imrpovements
TotallyNotChase Jul 10, 2022
581ff70
Add semantics documentation
TotallyNotChase Jul 10, 2022
cd74c2e
Fix formatting
TotallyNotChase Jul 10, 2022
ac6b59a
Fix builtin string prettification
TotallyNotChase Jul 10, 2022
b12ede0
Add example
TotallyNotChase Jul 10, 2022
bc7d54b
Merge pull request #461 from Plutonomicon/pretty-scripts
L-as Jul 11, 2022
bb4fe78
Merge branch 'staging' into mangoiv/interval-utils
L-as Jul 11, 2022
0729fed
Actually export `pthrow`
TotallyNotChase Jul 12, 2022
cb73a12
Use `pthrow` for compilation error
TotallyNotChase Jul 12, 2022
03fe4ec
Don't use `punsafeCoerce` unless necessary
TotallyNotChase Jul 12, 2022
74b01ac
Fix formatting
TotallyNotChase Jul 12, 2022
92e3d6d
Add link to Discord
L-as Jul 12, 2022
67dc9cc
Merge pull request #517 from Plutonomicon/las/readme
L-as Jul 12, 2022
9f437c1
Remove `PBuiltinMap`
L-as Jul 12, 2022
e103d25
Merge pull request #518 from Plutonomicon/las/pbuiltinmap
L-as Jul 12, 2022
6363411
Merge branch 'staging' into mangoiv/interval-utils
L-as Jul 12, 2022
585fe59
Put some tests inside `contains` test group
L-as Jul 12, 2022
b808c99
Merge pull request #514 from Plutonomicon/mangoiv/interval-utils
L-as Jul 12, 2022
e1f1936
Fix goldens
L-as Jul 12, 2022
fcc8ed8
Merge pull request #519 from Plutonomicon/las/goldens
L-as Jul 12, 2022
8a5973e
Use `PPositive` rather than `PNonZero` for `PRational`
TotallyNotChase Jul 12, 2022
c99ec7e
Fix formatting
TotallyNotChase Jul 12, 2022
fa14b22
Address review comments
TotallyNotChase Jul 13, 2022
4e02da9
Merge branch 'staging' into rational-experiment
L-as Jul 13, 2022
025b57d
Merge branch 'staging' into mangoiv/upstream-ptryFrom-instances
danielfarrelly Jul 13, 2022
1aecbb4
Merge pull request #435 from Plutonomicon/rational-experiment
L-as Jul 13, 2022
9d482e2
Update `PTryFrom` instances for Plutarch 1.2
danielfarrelly Jul 13, 2022
26e7f86
Merge branch 'staging' into df/upstream-ptryFrom-instances
L-as Jul 13, 2022
160cce0
Drop `PAsData` from TxInfo where it is redundant
emiflake Jul 14, 2022
829f7d6
Merge pull request #521 from Plutonomicon/emiflake/drop-as-data-api
L-as Jul 14, 2022
3574284
Partial ordering relations and type sig fixes
TotallyNotChase Jul 19, 2022
13547f4
Minor changes
TotallyNotChase Jul 20, 2022
4364bd0
More CSE in `pcheckBinRel`
TotallyNotChase Jul 20, 2022
96a58ef
Eta reduction for `pcheckBinRel`
TotallyNotChase Jul 20, 2022
273552f
Merge pull request #524 from Plutonomicon/pvalue-order
L-as Jul 20, 2022
ebc94bf
Fix parens wrapping on prettifier
TotallyNotChase Jul 20, 2022
c25c5a7
Merge pull request #527 from Plutonomicon/pretty-fix
L-as Jul 20, 2022
a8564db
Add `PPartialOrd`
TotallyNotChase Jul 22, 2022
3852f3a
Remove `POrd` instance of PValue
TotallyNotChase Jul 22, 2022
410c1d2
Fixity declaration for `PPartialOrd` methods
TotallyNotChase Jul 22, 2022
af33579
`PPartialOrd` and `POrd` rehaul
TotallyNotChase Jul 26, 2022
e297150
Merge branch 'staging' into pvalue-remove-pord
L-as Jul 26, 2022
e23f2d9
Merge pull request #528 from Plutonomicon/pvalue-remove-pord
L-as Jul 26, 2022
104fdc5
Merge branch 'staging' into df/upstream-ptryFrom-instances
TotallyNotChase Jul 28, 2022
0ecac88
Fix some `PValue` type sigs
TotallyNotChase Jul 28, 2022
3180ae4
`ptryFrom` error convention
TotallyNotChase Jul 28, 2022
d67e1ce
Fix test suite compilation
TotallyNotChase Jul 28, 2022
7bfb370
Improve `PTxId` `PTryFrom` instance
TotallyNotChase Jul 29, 2022
77bbe60
Remove `Flip` export and define inline everywhere
TotallyNotChase Jul 29, 2022
2f6faa2
Merge pull request #520 from danielfarrelly/df/upstream-ptryFrom-inst…
L-as Jul 30, 2022
a89859e
1.2
L-as Aug 1, 2022
ab34e54
Merge remote-tracking branch 'origin/master' into staging
L-as Aug 1, 2022
2629dc2
Merge pull request #530 from Plutonomicon/las/release
L-as Aug 1, 2022
45b7c77
Format
L-as Aug 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/result*
/dist-newstyle
.direnv
bench.csv
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

# Unreleased

- Add `pshow` and `ptraceShowId`

Started by [#352](https://github.com/Plutonomicon/plutarch/pull/352)

- Add `puncons` and `ptryUncons` functions for deconstructing list.

Started by: [#333](https://github.com/Plutonomicon/plutarch/pull/333)

- Add generic deriving for `PEq`

Started by [#335](https://github.com/Plutonomicon/plutarch/pull/335)

- `TermCont`: Parametrize by result type; add `MonadFail` instance; etc.

Also, export from `Plutarch.TermCont`, and then from `Plutarch.Prelude` (TermCont is no longer exported by `Plutarch.Internal`).
Expand Down Expand Up @@ -71,6 +83,15 @@

Added by: [#235](https://github.com/Plutonomicon/plutarch/pull/270)

- Add `Plutarch.Test` for testing Plutarch code with goldens for UPLC printing and Plutus benchmarks.

- `plutarch-extra`: Add a new directory scaffold "`plutarch-extra`" which will be home to everything too specific to not be in the
main Plutarch repo. Also refactored the test library.

Directory: `plutarch-extra`

Added by: [#329](https://github.com/Plutonomicon/plutarch/pull/329)

# 1.1.0

- General repository changes.
Expand Down
15 changes: 0 additions & 15 deletions CODEOWNERS

This file was deleted.

2 changes: 0 additions & 2 deletions Plutarch/Api/V1.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ module Plutarch.Api.V1 (

-- ** Crypto
Crypto.PPubKeyHash (PPubKeyHash),
Crypto.PPubKey (PPubKey),
Crypto.PSignature (PSignature),

-- ** DCert
DCert.PDCert (
Expand Down
26 changes: 2 additions & 24 deletions Plutarch/Api/V1/Crypto.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@

module Plutarch.Api.V1.Crypto (
PPubKeyHash (PPubKeyHash),
PPubKey (PPubKey),
PSignature (PSignature),
) where

import qualified Plutus.V1.Ledger.Api as Plutus
import qualified Plutus.V1.Ledger.Crypto as PlutusCrypto
import qualified PlutusTx.Builtins.Internal as PT

import Plutarch.Lift (
DerivePConstantViaNewtype (DerivePConstantViaNewtype),
DerivePConstantViaBuiltin (DerivePConstantViaBuiltin),
PLifted,
PUnsafeLiftDecl,
)
Expand All @@ -23,24 +19,6 @@ newtype PPubKeyHash (s :: S) = PPubKeyHash (Term s PByteString)

instance PUnsafeLiftDecl PPubKeyHash where type PLifted PPubKeyHash = Plutus.PubKeyHash
deriving via
(DerivePConstantViaNewtype Plutus.PubKeyHash PPubKeyHash PByteString)
(DerivePConstantViaBuiltin Plutus.PubKeyHash PPubKeyHash PByteString)
instance
(PConstant Plutus.PubKeyHash)

newtype PPubKey (s :: S) = PPubKey (Term s PByteString)
deriving (PlutusType, PIsData, PEq, POrd) via (DerivePNewtype PPubKey PByteString)

instance PUnsafeLiftDecl PPubKey where type PLifted PPubKey = PlutusCrypto.PubKey
deriving via
(DerivePConstantViaNewtype PlutusCrypto.PubKey PPubKey PByteString)
instance
(PConstant PlutusCrypto.PubKey)

newtype PSignature (s :: S) = PSignature (Term s PByteString)
deriving (PlutusType, PIsData, PEq, POrd) via (DerivePNewtype PSignature PByteString)

instance PUnsafeLiftDecl PSignature where type PLifted PSignature = PlutusCrypto.Signature
deriving via
(DerivePConstantViaNewtype PlutusCrypto.Signature PSignature PByteString)
instance
(PConstant PlutusCrypto.Signature)
15 changes: 7 additions & 8 deletions Plutarch/Api/V1/Scripts.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ module Plutarch.Api.V1.Scripts (
) where

import qualified Plutus.V1.Ledger.Api as Plutus
import qualified PlutusTx.Builtins.Internal as PT

import Plutarch.Lift (
DerivePConstantViaNewtype (DerivePConstantViaNewtype),
DerivePConstantViaBuiltin (DerivePConstantViaBuiltin),
PLifted,
PUnsafeLiftDecl,
)
Expand All @@ -25,26 +24,26 @@ newtype PDatum (s :: S) = PDatum (Term s PData)
deriving (PlutusType, PIsData, PEq) via (DerivePNewtype PDatum PData)

instance PUnsafeLiftDecl PDatum where type PLifted PDatum = Plutus.Datum
deriving via (DerivePConstantViaNewtype Plutus.Datum PDatum PData) instance (PConstant Plutus.Datum)
deriving via (DerivePConstantViaBuiltin Plutus.Datum PDatum PData) instance (PConstant Plutus.Datum)

newtype PRedeemer (s :: S) = PRedeemer (Term s PData)
deriving (PlutusType, PIsData, PEq) via (DerivePNewtype PRedeemer PData)

instance PUnsafeLiftDecl PRedeemer where type PLifted PRedeemer = Plutus.Redeemer
deriving via (DerivePConstantViaNewtype Plutus.Redeemer PRedeemer PData) instance (PConstant Plutus.Redeemer)
deriving via (DerivePConstantViaBuiltin Plutus.Redeemer PRedeemer PData) instance (PConstant Plutus.Redeemer)

newtype PDatumHash (s :: S) = PDatumHash (Term s PByteString)
deriving (PlutusType, PIsData, PEq, POrd) via (DerivePNewtype PDatumHash PByteString)

instance PUnsafeLiftDecl PDatumHash where type PLifted PDatumHash = Plutus.DatumHash
deriving via (DerivePConstantViaNewtype Plutus.DatumHash PDatumHash PByteString) instance (PConstant Plutus.DatumHash)
deriving via (DerivePConstantViaBuiltin Plutus.DatumHash PDatumHash PByteString) instance (PConstant Plutus.DatumHash)

newtype PStakeValidatorHash (s :: S) = PStakeValidatorHash (Term s PByteString)
deriving (PlutusType, PIsData, PEq, POrd) via (DerivePNewtype PStakeValidatorHash PByteString)

instance PUnsafeLiftDecl PStakeValidatorHash where type PLifted PStakeValidatorHash = Plutus.StakeValidatorHash
deriving via
(DerivePConstantViaNewtype Plutus.StakeValidatorHash PStakeValidatorHash PByteString)
(DerivePConstantViaBuiltin Plutus.StakeValidatorHash PStakeValidatorHash PByteString)
instance
(PConstant Plutus.StakeValidatorHash)

Expand All @@ -53,7 +52,7 @@ newtype PRedeemerHash (s :: S) = PRedeemerHash (Term s PByteString)

instance PUnsafeLiftDecl PRedeemerHash where type PLifted PRedeemerHash = Plutus.RedeemerHash
deriving via
(DerivePConstantViaNewtype Plutus.RedeemerHash PRedeemerHash PByteString)
(DerivePConstantViaBuiltin Plutus.RedeemerHash PRedeemerHash PByteString)
instance
(PConstant Plutus.RedeemerHash)

Expand All @@ -62,6 +61,6 @@ newtype PValidatorHash (s :: S) = PValidatorHash (Term s PByteString)

instance PUnsafeLiftDecl PValidatorHash where type PLifted PValidatorHash = Plutus.ValidatorHash
deriving via
(DerivePConstantViaNewtype Plutus.ValidatorHash PValidatorHash PByteString)
(DerivePConstantViaBuiltin Plutus.ValidatorHash PValidatorHash PByteString)
instance
(PConstant Plutus.ValidatorHash)
6 changes: 3 additions & 3 deletions Plutarch/Api/V1/Value.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ module Plutarch.Api.V1.Value (
) where

import qualified Plutus.V1.Ledger.Api as Plutus
import qualified PlutusTx.Builtins.Internal as PT

import Plutarch.Api.V1.AssocMap (PMap)
import Plutarch.Lift (
DerivePConstantViaBuiltin (DerivePConstantViaBuiltin),
DerivePConstantViaNewtype (DerivePConstantViaNewtype),
PLifted,
PUnsafeLiftDecl,
Expand All @@ -23,7 +23,7 @@ newtype PTokenName (s :: S) = PTokenName (Term s PByteString)

instance PUnsafeLiftDecl PTokenName where type PLifted PTokenName = Plutus.TokenName
deriving via
(DerivePConstantViaNewtype Plutus.TokenName PTokenName PByteString)
(DerivePConstantViaBuiltin Plutus.TokenName PTokenName PByteString)
instance
(PConstant Plutus.TokenName)

Expand All @@ -32,7 +32,7 @@ newtype PCurrencySymbol (s :: S) = PCurrencySymbol (Term s PByteString)

instance PUnsafeLiftDecl PCurrencySymbol where type PLifted PCurrencySymbol = Plutus.CurrencySymbol
deriving via
(DerivePConstantViaNewtype Plutus.CurrencySymbol PCurrencySymbol PByteString)
(DerivePConstantViaBuiltin Plutus.CurrencySymbol PCurrencySymbol PByteString)
instance
(PConstant Plutus.CurrencySymbol)

Expand Down
63 changes: 60 additions & 3 deletions Plutarch/Bool.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# LANGUAGE AllowAmbiguousTypes #-}
L-as marked this conversation as resolved.
Show resolved Hide resolved
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
Expand All @@ -17,6 +19,20 @@ module Plutarch.Bool (
por',
) where

import Data.Foldable (foldl')
import Generics.SOP (
All,
All2,
HCollapse (hcollapse),
K (K),
NP,
Proxy (Proxy),
SOP (SOP),
ccompare_NS,
hcliftA2,
)
import Plutarch.Internal (punsafeAsClosedTerm)
import Plutarch.Internal.Generic (PCode, PGeneric, gpfrom)
import Plutarch.Internal.Other (
DerivePNewtype,
PDelayed,
Expand Down Expand Up @@ -45,6 +61,7 @@ import qualified PlutusCore as PLC

-- | Plutus 'BuiltinBool'
data PBool (s :: S) = PTrue | PFalse
deriving stock (Show)

instance PUnsafeLiftDecl PBool where type PLifted PBool = Bool
deriving via (DerivePConstantDirect Bool PBool) instance (PConstant Bool)
Expand All @@ -57,6 +74,12 @@ instance PlutusType PBool where

class PEq t where
(#==) :: Term s t -> Term s t -> Term s PBool
default (#==) ::
(PGeneric s t, PlutusType t, All2 PEq (PCode s t)) =>
Term s t ->
Term s t ->
Term s PBool
a #== b = gpeq # a # b

infix 4 #==

Expand Down Expand Up @@ -88,7 +111,7 @@ pif b case_true case_false = pmatch b $ \case

-- | Boolean negation for 'PBool' terms.
pnot :: Term s (PBool :--> PBool)
pnot = phoistAcyclic $ plam $ \x -> pif x (pcon PFalse) $ pcon PTrue
pnot = phoistAcyclic $ plam $ \x -> pif' # x # pcon PFalse # pcon PTrue

-- | Lazily evaluated boolean and for 'PBool' terms.
infixr 3 #&&
Expand All @@ -112,8 +135,42 @@ pand' = phoistAcyclic $ plam $ \x y -> pif' # x # y # (pcon PFalse)

-- | Hoisted, Plutarch level, lazily evaluated boolean or function.
por :: Term s (PBool :--> PDelayed PBool :--> PDelayed PBool)
por = phoistAcyclic $ plam $ \x y -> pif' # x # (phoistAcyclic $ pdelay $ pcon PTrue) # y
por = phoistAcyclic $ plam $ \x -> pif' # x # (phoistAcyclic $ pdelay $ pcon PTrue)

-- | Hoisted, Plutarch level, strictly evaluated boolean or function.
por' :: Term s (PBool :--> PBool :--> PBool)
por' = phoistAcyclic $ plam $ \x y -> pif' # x # (pcon PTrue) # y
por' = phoistAcyclic $ plam $ \x -> pif' # x # (pcon PTrue)

-- | Generic version of (#==)
gpeq ::
forall t s.
( PGeneric s t
, PlutusType t
, All2 PEq (PCode s t)
) =>
Term s (t :--> t :--> PBool)
gpeq =
phoistAcyclic $
punsafeAsClosedTerm @s $
plam $ \x y ->
pmatch x $ \x' ->
pmatch y $ \y' ->
gpeq' @t (gpfrom x') (gpfrom y')

gpeq' ::
forall a s.
All2 PEq (PCode s a) =>
SOP (Term s) (PCode s a) ->
SOP (Term s) (PCode s a) ->
Term s PBool
gpeq' (SOP c1) (SOP c2) =
ccompare_NS (Proxy @(All PEq)) (pcon PFalse) eqProd (pcon PFalse) c1 c2
where
eqProd :: All PEq xs => NP (Term s) xs -> NP (Term s) xs -> Term s PBool
eqProd p1 p2 =
foldl' (#&&) (pcon PTrue) $
hcollapse $ hcliftA2 (Proxy :: Proxy PEq) eqTerm p1 p2
where
eqTerm :: forall a. PEq a => Term s a -> Term s a -> K (Term s PBool) a
eqTerm a b =
K $ a #== b
18 changes: 17 additions & 1 deletion Plutarch/Builtin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,20 @@ import Plutarch.Lift (
pconstantFromRepr,
pconstantToRepr,
)
import Plutarch.List (PListLike (..), plistEquals)
import Plutarch.List (
PListLike (
PElemConstraint,
pcons,
pelimList,
phead,
pnil,
pnull,
ptail
),
plistEquals,
pshowList,
)
import Plutarch.Show (PShow (pshow'))
import Plutarch.Unit (PUnit)
import Plutarch.Unsafe (punsafeBuiltin, punsafeCoerce, punsafeFrom)
import qualified PlutusCore as PLC
Expand Down Expand Up @@ -104,6 +117,9 @@ data PBuiltinList (a :: PType) (s :: S)
= PCons (Term s a) (Term s (PBuiltinList a))
| PNil

instance (PShow a, PLift a) => PShow (PBuiltinList a) where
pshow' _ x = pshowList @PBuiltinList @a # x

pheadBuiltin :: Term s (PBuiltinList a :--> a)
pheadBuiltin = phoistAcyclic $ pforce $ punsafeBuiltin PLC.HeadList

Expand Down
Loading