diff --git a/cabal.project b/cabal.project index 588b3ac..ccb34db 100644 --- a/cabal.project +++ b/cabal.project @@ -14,19 +14,19 @@ repository cardano-haskell-packages c00aae8461a256275598500ea0e187588c35a5d5d7454fb57eac18d9edb86a56 d4a35cd3121aa00d18544bb0ac01c3e1691d618f462c46129271bccf39f7e8ee -index-state: 2024-10-09T22:38:57Z - source-repository-package type: git - --sha256: sha256-lU2JF9KYvzEPfVLHdLkrM1hTTuc9NYi2hQPFnLDm2d8= - location: https://github.com/Plutonomicon/plutarch-plutus.git - tag: v1.10.1 + location: https://github.com/Plutonomicon/plutarch-plutus + tag: 0850d1c353f907e45da155215dbdd3123fa6e614 + --sha256: 17wxdfavjzbq0cgwr7bs45ma1lzxab417jqnbnkzas2zpp6i1ig5 subdir: . plutarch-ledger-api plutarch-orphanage plutarch-testlib +index-state: 2025-09-22T06:47:49Z + write-ghc-environment-files: never tests: true @@ -35,7 +35,7 @@ test-show-details: direct constraints: , dependent-sum >= 0.7.1.0 - , plutus-core ^>= 1.36.0.0 + , plutus-core == 1.54.0.0 package nothunks flags: +vector diff --git a/example/common/Example/Type.hs b/example/common/Example/Type.hs index f15667e..dcd83e9 100644 --- a/example/common/Example/Type.hs +++ b/example/common/Example/Type.hs @@ -5,7 +5,8 @@ module Example.Type (MyParameter (..)) where import GHC.Generics (Generic) -import PlutusLedgerApi.Data.V3 (TokenName, TxOutRef) +-- FIXME: import PlutusLedgerApi.Data.V3 (TokenName, TxOutRef) +import PlutusLedgerApi.V3 (TokenName, TxOutRef) import PlutusTx.Blueprint (HasBlueprintDefinition, definitionRef) import PlutusTx.Blueprint.TH (makeIsDataSchemaIndexed) import Ply (PlyArg) diff --git a/example/compiler-app/Main.hs b/example/compiler-app/Main.hs index 6a33a96..38070f5 100644 --- a/example/compiler-app/Main.hs +++ b/example/compiler-app/Main.hs @@ -9,7 +9,7 @@ import qualified Data.Text as Txt import System.FilePath (()) import qualified Cardano.Binary as CBOR -import Plutarch.Internal.Term (ClosedTerm, Config (Tracing), LogLevel (LogInfo), TracingMode (DoTracing), compile) +import Plutarch.Internal.Term (Config (Tracing), LogLevel (LogInfo), S, Term, TracingMode (DoTracing), compile) import Plutarch.LedgerApi.V3 (scriptHash) import Plutarch.Script (serialiseScript) import PlutusLedgerApi.V3 (ScriptHash (ScriptHash)) @@ -78,13 +78,13 @@ main = -- NOTE: Plutarch's scriptHash function is exported from V3 but hashes with V2 prefix. This is a bug. ScriptHash hash = scriptHash script -versionOf :: forall ptype. ReifyVersion (VersionOf ptype) => ClosedTerm ptype -> PlutusVersion +versionOf :: forall ptype. (ReifyVersion (VersionOf ptype)) => (forall (s :: S). Term s ptype) -> PlutusVersion versionOf _ = reifyVersion $ Proxy @(VersionOf ptype) -- Note: We have to manually prepend datum/redeemer to the types because it does not exist on the Plutarch type. -scriptDefinitions :: forall redeemer ptype. HasDefinitions (redeemer : ParamsOf ptype) => ClosedTerm ptype -> Definitions (ReferencedTypesOf (redeemer : ParamsOf ptype)) +scriptDefinitions :: forall redeemer ptype. (HasDefinitions (redeemer : ParamsOf ptype)) => (forall (s :: S). Term s ptype) -> Definitions (ReferencedTypesOf (redeemer : ParamsOf ptype)) scriptDefinitions _ = derivePDefinitions @(redeemer : ParamsOf ptype) -- Note: When using 'mkParamSchemas', the second type argument should only contain the params (i.e from 'ParamsOf'), not the datum/redeemer. -scriptParamSchemas :: forall redeemer ptype. HasDefinitions (redeemer : ParamsOf ptype) => ClosedTerm ptype -> [Schema (ReferencedTypesOf (redeemer : ParamsOf ptype))] +scriptParamSchemas :: forall redeemer ptype. (HasDefinitions (redeemer : ParamsOf ptype)) => (forall (s :: S). Term s ptype) -> [Schema (ReferencedTypesOf (redeemer : ParamsOf ptype))] scriptParamSchemas _ = mkParamSchemas @(ReferencedTypesOf (redeemer : ParamsOf ptype)) @(ParamsOf ptype) diff --git a/example/reader-app/Main.hs b/example/reader-app/Main.hs index 379528a..de72508 100644 --- a/example/reader-app/Main.hs +++ b/example/reader-app/Main.hs @@ -43,7 +43,7 @@ main = do nftMp #! MyParameter { myParameter'ref = TxOutRef {txOutRefId = "2be7c999fda3c9d4c3540bc9f4f28b78f8aacf9662b4489d8000bcdc18131268", txOutRefIdx = 0} - , myParameter'tn = "A" + , myParameter'tn = TokenName "A" } print policy diff --git a/example/src/Example/NftM.hs b/example/src/Example/NftM.hs index eb0daa3..e969942 100644 --- a/example/src/Example/NftM.hs +++ b/example/src/Example/NftM.hs @@ -8,7 +8,6 @@ import qualified Generics.SOP as SOP import Plutarch.LedgerApi.V3 import qualified Plutarch.LedgerApi.Value as PValue import Plutarch.Prelude -import Plutarch.Repr.Data (DeriveAsDataStruct (DeriveAsDataStruct)) import Ply.Plutarch (PlyArgOf) import Example.Type (MyParameter) @@ -31,18 +30,22 @@ deriving via type instance PlyArgOf PMyParameter = MyParameter -- | An example minting policy. -nftMp :: ClosedTerm (PMyParameter :--> PScriptContext :--> POpaque) +nftMp :: forall (s :: S). Term s (PMyParameter :--> PScriptContext :--> POpaque) nftMp = plam $ \param' ctx' -> popaque $ unTermCont $ do ctx <- pmatchC ctx' param <- pmatchC param' PMintingScript ownSym <- tcont $ pmatch $ pscriptContext'scriptInfo ctx txInfo <- pmatchC $ pscriptContext'txInfo ctx - pguardC "UTxO not consumed" $ - pany + pguardC "UTxO not consumed" + $ pany # plam (\x -> pmatch (pfromData x) $ \case x' -> ptxInInfo'outRef x' #== pmyParameter'ref param) #$ pfromData - $ ptxInfo'inputs txInfo + $ ptxInfo'inputs txInfo pguardC "Wrong NFT mint amount" $ - PValue.pvalueOf # pfromData (ptxInfo'mint txInfo) # pfromData ownSym # pfromData (pmyParameter'tn param) #== 1 + PValue.pvalueOf + # pto (pfromData (ptxInfo'mint txInfo)) + # pfromData ownSym + # pfromData (pmyParameter'tn param) + #== 1 pure . popaque $ pconstant @PUnit () diff --git a/flake.lock b/flake.lock index b6ad53c..7a6c04e 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "CHaP": { "flake": false, "locked": { - "lastModified": 1739645821, - "narHash": "sha256-HjAchUMLsiScm8Jyd+I/5YJKUjDp1r+XFzr05d+o+r4=", + "lastModified": 1768416233, + "narHash": "sha256-i2c7coWF4U8y9WwiwAQGu3RkLlJJUQgomBPqsuZ7aNc=", "owner": "input-output-hk", "repo": "cardano-haskell-packages", - "rev": "48b941c5729384f38b79c6f473ddbf920cb310ea", + "rev": "cb466bebf83011b95108c2bb1d2a7514446fc11b", "type": "github" }, "original": { @@ -36,16 +36,16 @@ "blst": { "flake": false, "locked": { - "lastModified": 1691598027, - "narHash": "sha256-oqljy+ZXJAXEB/fJtmB8rlAr4UXM+Z2OkDa20gpILNA=", + "lastModified": 1739372843, + "narHash": "sha256-IlbNMLBjs/dvGogcdbWQIL+3qwy7EXJbIDpo4xBd4bY=", "owner": "supranational", "repo": "blst", - "rev": "3dd0f804b1819e5d03fb22ca2e6fac105932043a", + "rev": "8c7db7fe8d2ce6e76dc398ebd4d475c0ec564355", "type": "github" }, "original": { "owner": "supranational", - "ref": "v0.3.11", + "ref": "v0.3.14", "repo": "blst", "type": "github" } @@ -134,13 +134,32 @@ "type": "github" } }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1767039857, + "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", + "owner": "NixOS", + "repo": "flake-compat", + "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "flake-compat", + "type": "github" + } + }, "flake-utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { @@ -149,67 +168,72 @@ "type": "github" } }, - "flake-utils_2": { + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks", + "nixpkgs" + ] + }, "locked": { - "lastModified": 1667077288, - "narHash": "sha256-bdC8sFNDpT0HK74u9fUkpbf1MEzVYJ+ka7NXCdgBoaA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "6ee9ebb6b1ee695d2cacc4faa053a7b9baa76817", + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "hercules-ci", + "repo": "gitignore.nix", "type": "github" } }, - "ghc-8.6.5-iohk": { + "hackage": { "flake": false, "locked": { - "lastModified": 1600920045, - "narHash": "sha256-DO6kxJz248djebZLpSzTGD6s8WRpNI9BTwUeOf5RwY8=", + "lastModified": 1768782566, + "narHash": "sha256-ejrmshhOsAqfxXLBGk7KufTfzTCA9eb5EElunEgJSVg=", "owner": "input-output-hk", - "repo": "ghc", - "rev": "95713a6ecce4551240da7c96b6176f980af75cae", + "repo": "hackage.nix", + "rev": "e2fdf467689a4ec0e4f3c14d59fdda6e0dab5ef9", "type": "github" }, "original": { "owner": "input-output-hk", - "ref": "release/8.6.5-iohk", - "repo": "ghc", + "repo": "hackage.nix", "type": "github" } }, - "hackage": { + "hackage-for-stackage": { "flake": false, "locked": { - "lastModified": 1739579010, - "narHash": "sha256-bgENCypknzmlsNdnUVK7tW1GKitYMFAOrErTcuewDMo=", + "lastModified": 1768782557, + "narHash": "sha256-I/lPQT4H+7ddkVCq6rABbwMWdHH3KbdbGCvnCKZRPMQ=", "owner": "input-output-hk", "repo": "hackage.nix", - "rev": "8e0217ce16b03a7e4e3751dc5577aa8498a6cac7", + "rev": "138c9656cd45ba549d604fd1e427fa8a947cfc19", "type": "github" }, "original": { "owner": "input-output-hk", + "ref": "for-stackage", "repo": "hackage.nix", "type": "github" } }, - "hackage-for-stackage": { + "hackage-internal": { "flake": false, "locked": { - "lastModified": 1739579000, - "narHash": "sha256-IFoCm65Mzr90YptIbz+l1LpbGVWhRrQjOsZ6mC/K3X0=", + "lastModified": 1750307553, + "narHash": "sha256-iiafNoeLHwlSLQTyvy8nPe2t6g5AV4PPcpMeH/2/DLs=", "owner": "input-output-hk", "repo": "hackage.nix", - "rev": "66a75c17c1a312b66ed27f8263661d41f10465b6", + "rev": "f7867baa8817fab296528f4a4ec39d1c7c4da4f3", "type": "github" }, "original": { "owner": "input-output-hk", - "ref": "for-stackage", "repo": "hackage.nix", "type": "github" } @@ -222,11 +246,15 @@ "cabal-36": "cabal-36", "cardano-shell": "cardano-shell", "flake-compat": "flake-compat", - "ghc-8.6.5-iohk": "ghc-8.6.5-iohk", "hackage": "hackage", "hackage-for-stackage": "hackage-for-stackage", + "hackage-internal": "hackage-internal", + "hls": "hls", "hls-1.10": "hls-1.10", "hls-2.0": "hls-2.0", + "hls-2.10": "hls-2.10", + "hls-2.11": "hls-2.11", + "hls-2.12": "hls-2.12", "hls-2.2": "hls-2.2", "hls-2.3": "hls-2.3", "hls-2.4": "hls-2.4", @@ -245,16 +273,18 @@ "nixpkgs-2311": "nixpkgs-2311", "nixpkgs-2405": "nixpkgs-2405", "nixpkgs-2411": "nixpkgs-2411", + "nixpkgs-2505": "nixpkgs-2505", + "nixpkgs-2511": "nixpkgs-2511", "nixpkgs-unstable": "nixpkgs-unstable", "old-ghc-nix": "old-ghc-nix", "stackage": "stackage" }, "locked": { - "lastModified": 1739617708, - "narHash": "sha256-dEH07wnBFaM/nCl7dNFHAnaAmZmTpK4wkeTnQt5DlGs=", + "lastModified": 1768783947, + "narHash": "sha256-J4EmObS7lV+YGKC8sc/r8HJdFalq/l/f0kN0FaHmka0=", "owner": "input-output-hk", "repo": "haskell.nix", - "rev": "fe9f1e6b75eaa0adb2c80925413ac4488322a158", + "rev": "8cbc9c467e3990204ebbafba29bd53f6bea60757", "type": "github" }, "original": { @@ -263,6 +293,22 @@ "type": "github" } }, + "hls": { + "flake": false, + "locked": { + "lastModified": 1741604408, + "narHash": "sha256-tuq3+Ip70yu89GswZ7DSINBpwRprnWnl6xDYnS4GOsc=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "682d6894c94087da5e566771f25311c47e145359", + "type": "github" + }, + "original": { + "owner": "haskell", + "repo": "haskell-language-server", + "type": "github" + } + }, "hls-1.10": { "flake": false, "locked": { @@ -297,6 +343,57 @@ "type": "github" } }, + "hls-2.10": { + "flake": false, + "locked": { + "lastModified": 1743069404, + "narHash": "sha256-q4kDFyJDDeoGqfEtrZRx4iqMVEC2MOzCToWsFY+TOzY=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "2318c61db3a01e03700bd4b05665662929b7fe8b", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.10.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.11": { + "flake": false, + "locked": { + "lastModified": 1747306193, + "narHash": "sha256-/MmtpF8+FyQlwfKHqHK05BdsxC9LHV70d/FiMM7pzBM=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "46ef4523ea4949f47f6d2752476239f1c6d806fe", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.11.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.12": { + "flake": false, + "locked": { + "lastModified": 1758709460, + "narHash": "sha256-xkI8MIIVEVARskfWbGAgP5sHG/lyeKnkm0LIOJ19X5w=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "7d983de4fa7ff54369f6dd31444bdb9869aec83e", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.12.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, "hls-2.2": { "flake": false, "locked": { @@ -419,11 +516,11 @@ "hls-2.9": { "flake": false, "locked": { - "lastModified": 1720003792, - "narHash": "sha256-qnDx8Pk0UxtoPr7BimEsAZh9g2WuTuMB/kGqnmdryKs=", + "lastModified": 1719993701, + "narHash": "sha256-wy348++MiMm/xwtI9M3vVpqj2qfGgnDcZIGXw8sF1sA=", "owner": "haskell", "repo": "haskell-language-server", - "rev": "0c1817cb2babef0765e4e72dd297c013e8e3d12b", + "rev": "90319a7e62ab93ab65a95f8f2bcf537e34dae76a", "type": "github" }, "original": { @@ -457,11 +554,11 @@ "sodium": "sodium" }, "locked": { - "lastModified": 1738874249, - "narHash": "sha256-oyPD/zIhs5AUEdYXZHluMAOmT5ynJSgjV2bNIXt5aKE=", + "lastModified": 1767797951, + "narHash": "sha256-74YzTQnjU8zXjFsSGNTElT/JrjEJ+UWxXP4W/aqegKk=", "owner": "input-output-hk", "repo": "iohk-nix", - "rev": "e26038d47df5d17187288fd7c8f5b915c9447b2e", + "rev": "a489231f4a6749fe6a81a63af7159d75bdaff700", "type": "github" }, "original": { @@ -473,11 +570,11 @@ "iserv-proxy": { "flake": false, "locked": { - "lastModified": 1717479972, - "narHash": "sha256-7vE3RQycHI1YT9LHJ1/fUaeln2vIpYm6Mmn8FTpYeVo=", + "lastModified": 1755243078, + "narHash": "sha256-GLbl1YaohKdpzZVJFRdcI1O1oE3F3uBer4lFv3Yy0l8=", "owner": "stable-haskell", "repo": "iserv-proxy", - "rev": "2ed34002247213fc435d0062350b91bab920626e", + "rev": "150605195cb7183a6fb7bed82f23fedf37c6f52a", "type": "github" }, "original": { @@ -489,16 +586,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1684171562, - "narHash": "sha256-BMUWjVWAUdyMWKk0ATMC9H0Bv4qAV/TXwwPUvTiC5IQ=", + "lastModified": 1751071626, + "narHash": "sha256-/uHE/AD2qGq4QLigWAnBHiVvpVXB04XAfrOtw8JMv+Y=", "owner": "nixos", "repo": "nixpkgs", - "rev": "55af203d468a6f5032a519cba4f41acf5a74b638", + "rev": "a47938d89bdf8e279ad432bd6a473cf4c430f48c", "type": "github" }, "original": { "owner": "nixos", - "ref": "release-22.11", + "ref": "release-25.05", "repo": "nixpkgs", "type": "github" } @@ -553,11 +650,11 @@ }, "nixpkgs-2411": { "locked": { - "lastModified": 1737255904, - "narHash": "sha256-r3fxHvh+M/mBgCZXOACzRFPsJdix2QSsKazb7VCXXo0=", + "lastModified": 1751290243, + "narHash": "sha256-kNf+obkpJZWar7HZymXZbW+Rlk3HTEIMlpc6FCNz0Ds=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "eacdab35066b0bb1c9413c96898e326b76398a81", + "rev": "5ab036a8d97cb9476fbe81b09076e6e91d15e1b6", "type": "github" }, "original": { @@ -567,13 +664,45 @@ "type": "github" } }, + "nixpkgs-2505": { + "locked": { + "lastModified": 1764560356, + "narHash": "sha256-M5aFEFPppI4UhdOxwdmceJ9bDJC4T6C6CzCK1E2FZyo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6c8f0cca84510cc79e09ea99a299c9bc17d03cb6", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-25.05-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2511": { + "locked": { + "lastModified": 1764572236, + "narHash": "sha256-hLp6T/vKdrBQolpbN3EhJOKTXZYxJZPzpnoZz+fEGlE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b0924ea1889b366de6bb0018a9db70b2c43a15f8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-25.11-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs-unstable": { "locked": { - "lastModified": 1737110817, - "narHash": "sha256-DSenga8XjPaUV5KUFW/i3rNkN7jm9XmguW+qQ1ZJTR4=", + "lastModified": 1764587062, + "narHash": "sha256-hdFa0TAVQAQLDF31cEW3enWmBP+b592OvHs6WVe3D8k=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "041c867bad68dfe34b78b2813028a2e2ea70a23c", + "rev": "c1cb7d097cb250f6e1904aacd5f2ba5ffd8a49ce", "type": "github" }, "original": { @@ -585,16 +714,18 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1667292599, - "narHash": "sha256-7ISOUI1aj6UKMPIL+wwthENL22L3+A9V+jS8Is3QsRo=", + "lastModified": 1764947035, + "narHash": "sha256-EYHSjVM4Ox4lvCXUMiKKs2vETUSL5mx+J2FfutM7T9w=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ef2f213d9659a274985778bff4ca322f3ef3ac68", + "rev": "a672be65651c80d3f592a89b3945466584a22069", "type": "github" }, "original": { - "id": "nixpkgs", - "type": "indirect" + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" } }, "old-ghc-nix": { @@ -616,15 +747,16 @@ }, "pre-commit-hooks": { "inputs": { - "flake-utils": "flake-utils_2", + "flake-compat": "flake-compat_2", + "gitignore": "gitignore", "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1667992213, - "narHash": "sha256-8Ens8ozllvlaFMCZBxg6S7oUyynYx2v7yleC5M0jJsE=", + "lastModified": 1768834646, + "narHash": "sha256-sZq+qm+Pg1jw+hxncm5LDujLxgPcAop3G55jPSvWhfU=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "ebcbfe09d2bd6d15f68de3a0ebb1e4dcb5cd324b", + "rev": "2f927757d32bcd2b11e5017bdb9f11fd9719af53", "type": "github" }, "original": { @@ -683,11 +815,11 @@ "stackage": { "flake": false, "locked": { - "lastModified": 1739578269, - "narHash": "sha256-qs0I3JIc1wGyTLcwq4PMQUaQ2hC2Yrn8XIrQ7nmuwts=", + "lastModified": 1768781731, + "narHash": "sha256-1L6oMW5nqYXVECHxKO0KBNrtfYVcW2X4Rbo2V7PpIig=", "owner": "input-output-hk", "repo": "stackage.nix", - "rev": "ff39c1b5a985f8d22d3bfd5e5439039263075303", + "rev": "c22f42c842a403aa17dd8aaba6fbaf92e97f7d7a", "type": "github" }, "original": { @@ -695,6 +827,21 @@ "repo": "stackage.nix", "type": "github" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index eaf0ea9..43c027d 100644 --- a/flake.nix +++ b/flake.nix @@ -54,7 +54,8 @@ ply = pkgs.haskell-nix.cabalProject' { src = ./.; - compiler-nix-name = "ghc96"; + compiler-nix-name = "ghc984"; + index-state = "2025-09-22T06:47:49Z"; shell = { # This is used by `nix develop .` to open a shell for use with # `cabal`, `hlint` and `haskell-language-server` etc diff --git a/ply-core/test/Unit/Schema.hs b/ply-core/test/Unit/Schema.hs index 4f1268d..16e1530 100644 --- a/ply-core/test/Unit/Schema.hs +++ b/ply-core/test/Unit/Schema.hs @@ -8,11 +8,14 @@ import Data.Text (Text) import GHC.Generics (Generic) import Data.Aeson (FromJSON) -import qualified Data.Aeson as Aeson -import PlutusLedgerApi.Data.V3 (Address, BuiltinByteString, BuiltinData, Credential, CurrencySymbol, DatumHash, Interval, POSIXTime, PubKeyHash, RedeemerHash, ScriptHash, StakingCredential, TokenName, TxId, TxOutRef, Value) +import Data.Aeson qualified as Aeson + +-- FIXME: import PlutusLedgerApi.Data.V3 (Address, BuiltinByteString, BuiltinData, Credential, CurrencySymbol, DatumHash, Interval, POSIXTime, PubKeyHash, RedeemerHash, ScriptHash, StakingCredential, TokenName, TxId, TxOutRef, Value) + import PlutusLedgerApi.V1.Value (AssetClass) +import PlutusLedgerApi.V3 (Address, BuiltinByteString, BuiltinData, Credential, CurrencySymbol, DatumHash, Interval, POSIXTime, PubKeyHash, RedeemerHash, ScriptHash, StakingCredential, TokenName, TxId, TxOutRef, Value) import PlutusTx.Blueprint (DefinitionsFor, HasBlueprintDefinition, UnrollAll, definitionRef, definitionsToMap, deriveDefinitions) -import qualified PlutusTx.Ratio as PlutusTx +import PlutusTx.Ratio qualified as PlutusTx import Test.Tasty (TestTree, testGroup) import Test.Tasty.HUnit (Assertion, assertBool, assertFailure, testCase) diff --git a/ply-plutarch/src/Ply/Plutarch/Class.hs b/ply-plutarch/src/Ply/Plutarch/Class.hs index 65755c5..6f692f0 100644 --- a/ply-plutarch/src/Ply/Plutarch/Class.hs +++ b/ply-plutarch/src/Ply/Plutarch/Class.hs @@ -5,11 +5,10 @@ module Ply.Plutarch.Class (PlyArgOf) where import Data.ByteString (ByteString) import Data.Kind (Type) -import Plutarch.Internal.Term (PType) -import Plutarch.LedgerApi.AssocMap (KeyGuarantees (Unsorted), PMap) +import Plutarch.LedgerApi.AssocMap (PAssocMap) import Plutarch.LedgerApi.Utils import qualified Plutarch.LedgerApi.V3 as PLedger.V3 -import Plutarch.LedgerApi.Value (AmountGuarantees (NoGuarantees), PValue) +import Plutarch.LedgerApi.Value (PRawValue) import Plutarch.Prelude import PlutusLedgerApi.V3 as Ledger.V3 import qualified PlutusTx.AssocMap as PlutusMap @@ -20,7 +19,7 @@ import qualified PlutusTx.Ratio as PlutusTx See the Haskell types HasBlueprintSchema instance and figure out which Plutarch type it corresponds to! For example, Integer's blueprint schema actually corresponds to PAsData PInteger. -} -type PlyArgOf :: PType -> Type +type PlyArgOf :: (S -> Type) -> Type type family PlyArgOf a = r | r -> a type instance PlyArgOf (PAsData PInteger) = Integer @@ -35,9 +34,17 @@ type instance PlyArgOf PRationalData = PlutusTx.Rational type instance PlyArgOf (PMaybeData a) = Maybe (PlyArgOf a) -type instance PlyArgOf (PAsData (PMap Unsorted a b)) = PlutusMap.Map (PlyArgOf a) (PlyArgOf b) +type instance PlyArgOf (PAsData (PAssocMap a b)) = PlutusMap.Map (PlyArgOf a) (PlyArgOf b) -type instance PlyArgOf (PAsData (PValue Unsorted NoGuarantees)) = Value +-- type instance PlyArgOf (PAsData (PUnsortedMap a b)) = PlutusMap.Map (PlyArgOf a) (PlyArgOf b) + +-- type instance PlyArgOf (PAsData (PSortedMap a b)) = PlutusMap.Map (PlyArgOf a) (PlyArgOf b) + +type instance PlyArgOf (PAsData PRawValue) = Value + +-- type instance PlyArgOf (PAsData PSortedValue) = Value + +-- type instance PlyArgOf (PAsData PLedgerValue) = Value type instance PlyArgOf PLedger.V3.PCredential = Credential diff --git a/ply-plutarch/src/Ply/Plutarch/TypedWriter.hs b/ply-plutarch/src/Ply/Plutarch/TypedWriter.hs index 8fd7e8b..2a83363 100644 --- a/ply-plutarch/src/Ply/Plutarch/TypedWriter.hs +++ b/ply-plutarch/src/Ply/Plutarch/TypedWriter.hs @@ -18,7 +18,6 @@ import GHC.TypeLits (ErrorMessage (ShowType, Text, (:$$:), (:<>:)), TypeError) import Generics.SOP (All, K (K), NP) import Generics.SOP.NP (collapse_NP, cpure_NP) -import Plutarch.Internal.Term (PType) import Plutarch.LedgerApi.V3 (PScriptContext) import Plutarch.Prelude import PlutusTx.Blueprint (Definitions, DefinitionsFor, HasBlueprintDefinition, PlutusVersion (PlutusV3), Schema, UnrollAll, definitionRef) @@ -56,14 +55,14 @@ with 'pdefinitionRef' and 'derivePDefinitions'. -} type HasDefinitions ptypes = (DefinitionsFor (ReferencedTypesOf ptypes), All (HasArgDefinition (ReferencedTypesOf ptypes)) ptypes) -type HasArgDefinition :: [Type] -> PType -> Constraint -class HasBlueprintDefinition (PlyArgOf ptype) => HasArgDefinition referencedTypes ptype where +type HasArgDefinition :: [Type] -> (S -> Type) -> Constraint +class (HasBlueprintDefinition (PlyArgOf ptype)) => HasArgDefinition referencedTypes ptype where -- | Plutarch version of 'definitionRef' pdefinitionRef :: Schema referencedTypes -- We can't just use 'Compose HasBlueprintDefinition PlyArgOf' instead of this class -- because PlyArgOf is a type family and cannot be passed unapplied! -instance HasBlueprintDefinition (PlyArgOf ptype) => HasArgDefinition referencedTypes ptype where +instance (HasBlueprintDefinition (PlyArgOf ptype)) => HasArgDefinition referencedTypes ptype where pdefinitionRef = definitionRef @(PlyArgOf ptype) {- | Given a list of Plutarch types, create the associated (as determined by 'PlyArgOf') Plutus blueprint @@ -86,22 +85,22 @@ mkParamSchemas @(ParamsOf (PTxOutRef :--> PData :--> PData :--> PScriptContext)) @ -} -mkParamSchemas :: forall (referencedTypes :: [Type]) (ptypes :: [PType]). All (HasArgDefinition referencedTypes) ptypes => [Schema referencedTypes] +mkParamSchemas :: forall (referencedTypes :: [Type]) (ptypes :: [S -> Type]). (All (HasArgDefinition referencedTypes) ptypes) => [Schema referencedTypes] mkParamSchemas = collapse_NP np where np :: NP (K (Schema referencedTypes)) ptypes np = cpure_NP (Proxy @(HasArgDefinition referencedTypes)) f -- The 'a' type parameter has to be applied explicitly, so we can't just inline this in place of 'f' and expect 'a' to be inferred based on expected type. - f :: forall (a :: PType). HasArgDefinition referencedTypes a => K (Schema referencedTypes) a + f :: forall (a :: S -> Type). (HasArgDefinition referencedTypes a) => K (Schema referencedTypes) a f = K $ pdefinitionRef @referencedTypes @a {- | Derive the schema definitions for the parameters, datum and redeemer of a script. Use it in conjuction with 'ReferencedTypesOf' to obtain the definitions needed for a script -} -derivePDefinitions :: forall (ptypes :: [PType]). HasDefinitions ptypes => Definitions (ReferencedTypesOf ptypes) +derivePDefinitions :: forall (ptypes :: [S -> Type]). (HasDefinitions ptypes) => Definitions (ReferencedTypesOf ptypes) derivePDefinitions = deriveDefinitions @(MapPlyArgOf ptypes) -type MapPlyArgOf :: [PType] -> [Type] +type MapPlyArgOf :: [S -> Type] -> [Type] type family MapPlyArgOf xs where MapPlyArgOf '[] = '[] MapPlyArgOf (x ': xs) = PlyArgOf x ': MapPlyArgOf xs @@ -126,7 +125,7 @@ minting policy with an extra 'PData' parameter? Or is it a validator? Currently, the Validator choice is given precedence. If you wanted to use the alternative meaning, use: `PAsData PData :--> PData :--> PScriptContext :--> PUnit` instead. -} -type ParamsOf :: PType -> [PType] +type ParamsOf :: (S -> Type) -> [S -> Type] type family ParamsOf a where ParamsOf (PScriptContext :--> POpaque) = '[] ParamsOf (PScriptContext :--> PUnit) = '[] @@ -141,7 +140,7 @@ type family ParamsOf a where 'PData :--> PData :--> PScriptContext :--> PUnit' or 'PData :--> PScriptContext :--> PUnit' -} -type VersionOf :: PType -> PlutusVersion +type VersionOf :: (S -> Type) -> PlutusVersion type family VersionOf a where VersionOf (PScriptContext :--> POpaque) = PlutusV3 VersionOf (PScriptContext :--> PUnit) = PlutusV3 @@ -152,8 +151,8 @@ type family VersionOf a where :$$: 'Text "But reached: " :<>: ShowType wrong ) --- | Map 'PlyArgOf' over a list of 'PType's. -type PlyParamsOf :: [PType] -> [Type] +-- | Map 'PlyArgOf' over a list of Plutarch types. +type PlyParamsOf :: [S -> Type] -> [Type] type family PlyParamsOf pts = r | r -> pts where PlyParamsOf '[] = '[] PlyParamsOf (x : xs) = PlyArgOf x : PlyParamsOf xs diff --git a/ply-plutarch/test/Spec.hs b/ply-plutarch/test/Spec.hs index fa6536f..72fbeff 100644 --- a/ply-plutarch/test/Spec.hs +++ b/ply-plutarch/test/Spec.hs @@ -4,10 +4,10 @@ module Main (main) where import Data.ByteString (ByteString) -import Plutarch.Internal.Term (PType, punsafeConstantInternal) -import Plutarch.LedgerApi.AssocMap (KeyGuarantees (Unsorted)) +import Data.Kind (Type) +import Plutarch.Internal.Term (punsafeConstantInternal) import qualified Plutarch.LedgerApi.V3 as PLedger.V3 -import Plutarch.LedgerApi.Value (AmountGuarantees (NoGuarantees), PValue) +import Plutarch.LedgerApi.Value (PRawValue) import Plutarch.Prelude import Plutarch.Test.QuickCheck (propEvalEqual) import PlutusLedgerApi.Common (BuiltinData, fromBuiltin, toBuiltin) @@ -17,7 +17,7 @@ import Ply.Plutarch.Class (PlyArgOf) import Test.QuickCheck (Arbitrary) import Test.Tasty -prop :: forall (a :: PType). (Arbitrary (PlyArgOf a), Show (PlyArgOf a), PlyArg (PlyArgOf a), PLiftable a, AsHaskell a ~ PlyArgOf a) => TestName -> TestTree +prop :: forall (a :: S -> Type). (Arbitrary (PlyArgOf a), Show (PlyArgOf a), PlyArg (PlyArgOf a), PLiftable a, AsHaskell a ~ PlyArgOf a) => TestName -> TestTree prop name = propEvalEqual @(PlyArgOf a) name (pconstant @a) (punsafeConstantInternal . toSomeBuiltinArg) tests :: TestTree @@ -28,7 +28,7 @@ tests = , propEvalEqual @ByteString "bytestring" (pdata . pconstant @PByteString) (punsafeConstantInternal . toSomeBuiltinArg . toBuiltin) , propEvalEqual @BuiltinData "builtin-data" (pdata . pconstant @PData . fromBuiltin) (punsafeConstantInternal . toSomeBuiltinArg) , prop @PLedger.V3.PRationalData "rational" - , prop @(PAsData (PValue Unsorted NoGuarantees)) "value" + , prop @(PAsData PRawValue) "value" , prop @PLedger.V3.PCredential "credential" , prop @PLedger.V3.PStakingCredential "staking-credential" , prop @PLedger.V3.PAddress "address"