upstream Agora extras
This commit is contained in:
parent
0f602de040
commit
d28ee8c928
4 changed files with 13 additions and 88 deletions
|
|
@ -95,6 +95,7 @@ common deps
|
||||||
, data-default-class
|
, data-default-class
|
||||||
, generics-sop
|
, generics-sop
|
||||||
, plutarch
|
, plutarch
|
||||||
|
, plutarch-extra
|
||||||
, plutus-core
|
, plutus-core
|
||||||
, plutus-ledger-api
|
, plutus-ledger-api
|
||||||
, plutus-tx
|
, plutus-tx
|
||||||
|
|
@ -128,8 +129,6 @@ library
|
||||||
other-modules:
|
other-modules:
|
||||||
Agora.Utils
|
Agora.Utils
|
||||||
Agora.Utils.Value
|
Agora.Utils.Value
|
||||||
Plutarch.Api.V1.These
|
|
||||||
Plutarch.These
|
|
||||||
|
|
||||||
hs-source-dirs: agora
|
hs-source-dirs: agora
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
||||||
{-# OPTIONS_GHC -Wno-orphans #-}
|
|
||||||
|
|
||||||
module Plutarch.Api.V1.These (PTheseData (..)) where
|
|
||||||
|
|
||||||
import GHC.Generics qualified as GHC
|
|
||||||
import Generics.SOP
|
|
||||||
import Plutarch.DataRepr (PIsDataReprInstances (PIsDataReprInstances))
|
|
||||||
import Plutarch.Lift (
|
|
||||||
PConstantRepr,
|
|
||||||
PConstanted,
|
|
||||||
PLifted,
|
|
||||||
PUnsafeLiftDecl,
|
|
||||||
pconstantFromRepr,
|
|
||||||
pconstantToRepr,
|
|
||||||
)
|
|
||||||
import Plutus.V1.Ledger.Api qualified as Plutus
|
|
||||||
import PlutusTx.These qualified as PlutusThese
|
|
||||||
|
|
||||||
data PTheseData (a :: PType) (b :: PType) (s :: S)
|
|
||||||
= PDThis (Term s (PDataRecord '["_0" ':= a]))
|
|
||||||
| PDThat (Term s (PDataRecord '["_0" ':= b]))
|
|
||||||
| PDThese (Term s (PDataRecord '["_0" ':= a, "_1" ':= b]))
|
|
||||||
deriving stock (GHC.Generic)
|
|
||||||
deriving anyclass (Generic, PIsDataRepr)
|
|
||||||
deriving
|
|
||||||
(PlutusType, PIsData)
|
|
||||||
via PIsDataReprInstances (PTheseData a b)
|
|
||||||
|
|
||||||
instance
|
|
||||||
( Plutus.ToData (PLifted a)
|
|
||||||
, Plutus.ToData (PLifted b)
|
|
||||||
, Plutus.FromData (PLifted a)
|
|
||||||
, Plutus.FromData (PLifted b)
|
|
||||||
, PLift a
|
|
||||||
, PLift b
|
|
||||||
) =>
|
|
||||||
PUnsafeLiftDecl (PTheseData a b)
|
|
||||||
where
|
|
||||||
type PLifted (PTheseData a b) = PlutusThese.These (PLifted a) (PLifted b)
|
|
||||||
|
|
||||||
{- TODO: Make PTheseData an instance of PConstant:
|
|
||||||
https://github.com/Plutonomicon/plutarch/pull/355
|
|
||||||
-}
|
|
||||||
|
|
||||||
instance
|
|
||||||
( PLifted (PConstanted a) ~ a
|
|
||||||
, Plutus.ToData b
|
|
||||||
, Plutus.FromData b
|
|
||||||
, Plutus.ToData a
|
|
||||||
, Plutus.FromData a
|
|
||||||
, PConstant a
|
|
||||||
, PLifted (PConstanted b) ~ b
|
|
||||||
, Plutus.FromData b
|
|
||||||
, Plutus.ToData b
|
|
||||||
, PConstant b
|
|
||||||
) =>
|
|
||||||
PConstant (PlutusThese.These a b)
|
|
||||||
where
|
|
||||||
type PConstantRepr (PlutusThese.These a b) = [(Plutus.Data, Plutus.Data)]
|
|
||||||
type PConstanted (PlutusThese.These a b) = PTheseData (PConstanted a) (PConstanted b)
|
|
||||||
pconstantToRepr _t = undefined
|
|
||||||
pconstantFromRepr _t = undefined
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
module Plutarch.These (PThese (..)) where
|
|
||||||
|
|
||||||
import GHC.Generics qualified as GHC
|
|
||||||
import Generics.SOP
|
|
||||||
|
|
||||||
-- | Plutus These type with Scott-encoded representation.
|
|
||||||
data PThese (a :: PType) (b :: PType) (s :: S)
|
|
||||||
= PThis (Term s a)
|
|
||||||
| PThat (Term s b)
|
|
||||||
| PThese (Term s a) (Term s b)
|
|
||||||
deriving stock (GHC.Generic)
|
|
||||||
deriving anyclass (Generic, PlutusType)
|
|
||||||
24
flake.lock
generated
24
flake.lock
generated
|
|
@ -885,11 +885,11 @@
|
||||||
"iohk-nix_2": {
|
"iohk-nix_2": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1646330344,
|
"lastModified": 1648032999,
|
||||||
"narHash": "sha256-EbhMDeneH26wDi+x5kz8nfru/dE9JZ241hJed4a8lz8=",
|
"narHash": "sha256-3uCz+gJppvM7z6CUCkBbFSu60WgIE+e3oXwXiAiGWSY=",
|
||||||
"owner": "input-output-hk",
|
"owner": "input-output-hk",
|
||||||
"repo": "iohk-nix",
|
"repo": "iohk-nix",
|
||||||
"rev": "0a0126d8fb1bdc61ce1fd2ef61cf396de800fdad",
|
"rev": "5e667b374153327c7bdfdbfab8ef19b1f27d4aac",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -1095,11 +1095,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs-2111_2": {
|
"nixpkgs-2111_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1646844010,
|
"lastModified": 1647902355,
|
||||||
"narHash": "sha256-NRDLmpjmBMNBRr/BiztSsGht5wJYl8WZFzj+b+6LhLk=",
|
"narHash": "sha256-SySJ8IRaogpc/BPOkysA+kzq9URvXthoeKIemaTKCiM=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "d59edd3833597be12763f1f017c7ad666cf1b810",
|
"rev": "31aa631dbc496500efd2507baaed39626f6650f2",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -1127,11 +1127,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs-2111_4": {
|
"nixpkgs-2111_4": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1647902355,
|
"lastModified": 1644510859,
|
||||||
"narHash": "sha256-SySJ8IRaogpc/BPOkysA+kzq9URvXthoeKIemaTKCiM=",
|
"narHash": "sha256-xjpVvL5ecbyi0vxtVl/Fh9bwGlMbw3S06zE5nUzFB8A=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "31aa631dbc496500efd2507baaed39626f6650f2",
|
"rev": "0d1d5d7e3679fec9d07f2eb804d9f9fdb98378d3",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -1302,11 +1302,11 @@
|
||||||
"validity": "validity"
|
"validity": "validity"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1648145467,
|
"lastModified": 1648163186,
|
||||||
"narHash": "sha256-yrq0CJbZPrDmrEeI/RqNmKGHoHasMsnknug7kPLUsRU=",
|
"narHash": "sha256-UfaSb4nk9HWzsj1Kb8RJuPV+iw1Nl4E2+97KOwIwcao=",
|
||||||
"owner": "peter-mlabs",
|
"owner": "peter-mlabs",
|
||||||
"repo": "plutarch",
|
"repo": "plutarch",
|
||||||
"rev": "2ddf1d1b6efc43598ca3502471f6ace596f920ec",
|
"rev": "0638dbd706bc2c5f48f9f40be7bbe1986a778698",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue