{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RoleAnnotations #-}
{-# OPTIONS_GHC -Wno-orphans #-}

{- | Value-related functionality. In order to keep the interface efficient and
 safe at the same time, there is a type-level distinction between 'PValue's
 that are guaranteed to be properly normalized and those that provide no
 such guarantee.

 Also for efficiency reasons, the Ada-specific functions assume that there
 can be only one token name for the Ada currency symbol, and they don't check
 whether it matches 'Plutus.adaToken'.
-}
module Plutarch.LedgerApi.Value (
  -- * Types
  PValue (..),
  PCurrencySymbol (..),
  PTokenName (..),
  AmountGuarantees (..),
  PLovelace (..),
  PAssetClass (..),

  -- * Functions

  -- ** Creation

  -- *** PCurrencySymbol
  padaSymbol,
  padaSymbolData,

  -- *** PTokenName
  padaToken,

  -- *** PValue
  psingleton,
  psingletonData,
  pconstantPositiveSingleton,

  -- ** Transformation
  passertPositive,
  passertNonZero,
  passertSorted,
  pforgetPositive,
  pforgetSorted,
  pnormalize,
  padaOnlyValue,
  pnoAdaValue,

  -- ** Partial ordering
  pltPositive,
  pltNonZero,
  pleqPositive,
  pleqNonZero,
  pcheckBinRel,

  -- ** Combination
  pleftBiasedCurrencyUnion,
  pleftBiasedTokenUnion,
  punionResolvingCollisionsWith,
  punionResolvingCollisionsWithData,

  -- ** Queries
  pvalueOf,
  plovelaceValueOf,
  pisAdaOnlyValue,
) where

import Data.Kind (Type)
import GHC.Generics (Generic)
import Plutarch.LedgerApi.AssocMap qualified as AssocMap
import Plutarch.LedgerApi.Utils (Mret)
import Plutarch.Prelude hiding (psingleton)
import Plutarch.Prelude qualified as PPrelude
import Plutarch.Unsafe (punsafeCoerce, punsafeDowncast)
import PlutusLedgerApi.V1.Value qualified as PlutusValue
import PlutusLedgerApi.V3 qualified as Plutus
import PlutusTx.Prelude qualified as PlutusTx

-- | @since 2.2.0
newtype PLovelace (s :: S) = PLovelace (Term s (PDataNewtype PInteger))
  deriving stock
    ( -- | @since 2.2.0
      (forall x. PLovelace s -> Rep (PLovelace s) x)
-> (forall x. Rep (PLovelace s) x -> PLovelace s)
-> Generic (PLovelace s)
forall x. Rep (PLovelace s) x -> PLovelace s
forall x. PLovelace s -> Rep (PLovelace s) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (s :: S) x. Rep (PLovelace s) x -> PLovelace s
forall (s :: S) x. PLovelace s -> Rep (PLovelace s) x
$cfrom :: forall (s :: S) x. PLovelace s -> Rep (PLovelace s) x
from :: forall x. PLovelace s -> Rep (PLovelace s) x
$cto :: forall (s :: S) x. Rep (PLovelace s) x -> PLovelace s
to :: forall x. Rep (PLovelace s) x -> PLovelace s
Generic
    )
  deriving anyclass
    ( -- | @since 2.2.0
      (forall (s :: S). PLovelace s -> Term s (PInner PLovelace))
-> (forall (s :: S) (b :: PType).
    Term s (PInner PLovelace) -> (PLovelace s -> Term s b) -> Term s b)
-> PlutusType PLovelace
forall (s :: S). PLovelace s -> Term s (PInner PLovelace)
forall (s :: S) (b :: PType).
Term s (PInner PLovelace) -> (PLovelace s -> Term s b) -> Term s b
forall (a :: PType).
(forall (s :: S). a s -> Term s (PInner a))
-> (forall (s :: S) (b :: PType).
    Term s (PInner a) -> (a s -> Term s b) -> Term s b)
-> PlutusType a
$cpcon' :: forall (s :: S). PLovelace s -> Term s (PInner PLovelace)
pcon' :: forall (s :: S). PLovelace s -> Term s (PInner PLovelace)
$cpmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PLovelace) -> (PLovelace s -> Term s b) -> Term s b
pmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PLovelace) -> (PLovelace s -> Term s b) -> Term s b
PlutusType
    , -- | @since 2.2.0
      (forall (s :: S). Term s (PAsData PLovelace) -> Term s PLovelace)
-> (forall (s :: S). Term s PLovelace -> Term s PData)
-> PIsData PLovelace
forall (s :: S). Term s (PAsData PLovelace) -> Term s PLovelace
forall (s :: S). Term s PLovelace -> Term s PData
forall (a :: PType).
(forall (s :: S). Term s (PAsData a) -> Term s a)
-> (forall (s :: S). Term s a -> Term s PData) -> PIsData a
$cpfromDataImpl :: forall (s :: S). Term s (PAsData PLovelace) -> Term s PLovelace
pfromDataImpl :: forall (s :: S). Term s (PAsData PLovelace) -> Term s PLovelace
$cpdataImpl :: forall (s :: S). Term s PLovelace -> Term s PData
pdataImpl :: forall (s :: S). Term s PLovelace -> Term s PData
PIsData
    , -- | @since 2.2.0
      (forall (s :: S).
 Term s PLovelace -> Term s PLovelace -> Term s PBool)
-> PEq PLovelace
forall (s :: S).
Term s PLovelace -> Term s PLovelace -> Term s PBool
forall (t :: PType).
(forall (s :: S). Term s t -> Term s t -> Term s PBool) -> PEq t
$c#== :: forall (s :: S).
Term s PLovelace -> Term s PLovelace -> Term s PBool
#== :: forall (s :: S).
Term s PLovelace -> Term s PLovelace -> Term s PBool
PEq
    , -- | @since WIP
      PEq PLovelace
PEq PLovelace =>
(forall (s :: S).
 Term s PLovelace -> Term s PLovelace -> Term s PBool)
-> (forall (s :: S).
    Term s PLovelace -> Term s PLovelace -> Term s PBool)
-> (forall (s :: S).
    Term s PLovelace -> Term s PLovelace -> Term s PLovelace)
-> (forall (s :: S).
    Term s PLovelace -> Term s PLovelace -> Term s PLovelace)
-> POrd PLovelace
forall (s :: S).
Term s PLovelace -> Term s PLovelace -> Term s PBool
forall (s :: S).
Term s PLovelace -> Term s PLovelace -> Term s PLovelace
forall (t :: PType).
PEq t =>
(forall (s :: S). Term s t -> Term s t -> Term s PBool)
-> (forall (s :: S). Term s t -> Term s t -> Term s PBool)
-> (forall (s :: S). Term s t -> Term s t -> Term s t)
-> (forall (s :: S). Term s t -> Term s t -> Term s t)
-> POrd t
$c#<= :: forall (s :: S).
Term s PLovelace -> Term s PLovelace -> Term s PBool
#<= :: forall (s :: S).
Term s PLovelace -> Term s PLovelace -> Term s PBool
$c#< :: forall (s :: S).
Term s PLovelace -> Term s PLovelace -> Term s PBool
#< :: forall (s :: S).
Term s PLovelace -> Term s PLovelace -> Term s PBool
$cpmax :: forall (s :: S).
Term s PLovelace -> Term s PLovelace -> Term s PLovelace
pmax :: forall (s :: S).
Term s PLovelace -> Term s PLovelace -> Term s PLovelace
$cpmin :: forall (s :: S).
Term s PLovelace -> Term s PLovelace -> Term s PLovelace
pmin :: forall (s :: S).
Term s PLovelace -> Term s PLovelace -> Term s PLovelace
POrd
    , -- | @since 2.2.0
      (forall (s :: S). Bool -> Term s PLovelace -> Term s PString)
-> PShow PLovelace
forall (s :: S). Bool -> Term s PLovelace -> Term s PString
forall (t :: PType).
(forall (s :: S). Bool -> Term s t -> Term s PString) -> PShow t
$cpshow' :: forall (s :: S). Bool -> Term s PLovelace -> Term s PString
pshow' :: forall (s :: S). Bool -> Term s PLovelace -> Term s PString
PShow
    , -- | @since 3.1.0
      PTryFrom PData
    )

-- | @since 2.2.0
instance DerivePlutusType PLovelace where
  type DPTStrat _ = PlutusTypeNewtype

-- | @since WIP
deriving via
  DeriveDataPLiftable PLovelace Plutus.Lovelace
  instance
    PLiftable PLovelace

-- | @since 3.1.0
instance PTryFrom PData (PAsData PLovelace)

-- | @since 2.0.0
newtype PTokenName (s :: S) = PTokenName (Term s (PDataNewtype PByteString))
  deriving stock
    ( -- | @since 2.0.0
      (forall x. PTokenName s -> Rep (PTokenName s) x)
-> (forall x. Rep (PTokenName s) x -> PTokenName s)
-> Generic (PTokenName s)
forall x. Rep (PTokenName s) x -> PTokenName s
forall x. PTokenName s -> Rep (PTokenName s) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (s :: S) x. Rep (PTokenName s) x -> PTokenName s
forall (s :: S) x. PTokenName s -> Rep (PTokenName s) x
$cfrom :: forall (s :: S) x. PTokenName s -> Rep (PTokenName s) x
from :: forall x. PTokenName s -> Rep (PTokenName s) x
$cto :: forall (s :: S) x. Rep (PTokenName s) x -> PTokenName s
to :: forall x. Rep (PTokenName s) x -> PTokenName s
Generic
    )
  deriving anyclass
    ( -- | @since 2.0.0
      (forall (s :: S). PTokenName s -> Term s (PInner PTokenName))
-> (forall (s :: S) (b :: PType).
    Term s (PInner PTokenName)
    -> (PTokenName s -> Term s b) -> Term s b)
-> PlutusType PTokenName
forall (s :: S). PTokenName s -> Term s (PInner PTokenName)
forall (s :: S) (b :: PType).
Term s (PInner PTokenName)
-> (PTokenName s -> Term s b) -> Term s b
forall (a :: PType).
(forall (s :: S). a s -> Term s (PInner a))
-> (forall (s :: S) (b :: PType).
    Term s (PInner a) -> (a s -> Term s b) -> Term s b)
-> PlutusType a
$cpcon' :: forall (s :: S). PTokenName s -> Term s (PInner PTokenName)
pcon' :: forall (s :: S). PTokenName s -> Term s (PInner PTokenName)
$cpmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PTokenName)
-> (PTokenName s -> Term s b) -> Term s b
pmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PTokenName)
-> (PTokenName s -> Term s b) -> Term s b
PlutusType
    , -- | @since 2.0.0
      (forall (s :: S). Term s (PAsData PTokenName) -> Term s PTokenName)
-> (forall (s :: S). Term s PTokenName -> Term s PData)
-> PIsData PTokenName
forall (s :: S). Term s (PAsData PTokenName) -> Term s PTokenName
forall (s :: S). Term s PTokenName -> Term s PData
forall (a :: PType).
(forall (s :: S). Term s (PAsData a) -> Term s a)
-> (forall (s :: S). Term s a -> Term s PData) -> PIsData a
$cpfromDataImpl :: forall (s :: S). Term s (PAsData PTokenName) -> Term s PTokenName
pfromDataImpl :: forall (s :: S). Term s (PAsData PTokenName) -> Term s PTokenName
$cpdataImpl :: forall (s :: S). Term s PTokenName -> Term s PData
pdataImpl :: forall (s :: S). Term s PTokenName -> Term s PData
PIsData
    , -- | @since 2.0.0
      (forall (s :: S).
 Term s PTokenName -> Term s PTokenName -> Term s PBool)
-> PEq PTokenName
forall (s :: S).
Term s PTokenName -> Term s PTokenName -> Term s PBool
forall (t :: PType).
(forall (s :: S). Term s t -> Term s t -> Term s PBool) -> PEq t
$c#== :: forall (s :: S).
Term s PTokenName -> Term s PTokenName -> Term s PBool
#== :: forall (s :: S).
Term s PTokenName -> Term s PTokenName -> Term s PBool
PEq
    , -- | @since 2.0.0
      PEq PTokenName
PEq PTokenName =>
(forall (s :: S).
 Term s PTokenName -> Term s PTokenName -> Term s PBool)
-> (forall (s :: S).
    Term s PTokenName -> Term s PTokenName -> Term s PBool)
-> (forall (s :: S).
    Term s PTokenName -> Term s PTokenName -> Term s PTokenName)
-> (forall (s :: S).
    Term s PTokenName -> Term s PTokenName -> Term s PTokenName)
-> POrd PTokenName
forall (s :: S).
Term s PTokenName -> Term s PTokenName -> Term s PBool
forall (s :: S).
Term s PTokenName -> Term s PTokenName -> Term s PTokenName
forall (t :: PType).
PEq t =>
(forall (s :: S). Term s t -> Term s t -> Term s PBool)
-> (forall (s :: S). Term s t -> Term s t -> Term s PBool)
-> (forall (s :: S). Term s t -> Term s t -> Term s t)
-> (forall (s :: S). Term s t -> Term s t -> Term s t)
-> POrd t
$c#<= :: forall (s :: S).
Term s PTokenName -> Term s PTokenName -> Term s PBool
#<= :: forall (s :: S).
Term s PTokenName -> Term s PTokenName -> Term s PBool
$c#< :: forall (s :: S).
Term s PTokenName -> Term s PTokenName -> Term s PBool
#< :: forall (s :: S).
Term s PTokenName -> Term s PTokenName -> Term s PBool
$cpmax :: forall (s :: S).
Term s PTokenName -> Term s PTokenName -> Term s PTokenName
pmax :: forall (s :: S).
Term s PTokenName -> Term s PTokenName -> Term s PTokenName
$cpmin :: forall (s :: S).
Term s PTokenName -> Term s PTokenName -> Term s PTokenName
pmin :: forall (s :: S).
Term s PTokenName -> Term s PTokenName -> Term s PTokenName
POrd
    , -- | @since 2.0.0
      (forall (s :: S). Bool -> Term s PTokenName -> Term s PString)
-> PShow PTokenName
forall (s :: S). Bool -> Term s PTokenName -> Term s PString
forall (t :: PType).
(forall (s :: S). Bool -> Term s t -> Term s PString) -> PShow t
$cpshow' :: forall (s :: S). Bool -> Term s PTokenName -> Term s PString
pshow' :: forall (s :: S). Bool -> Term s PTokenName -> Term s PString
PShow
    )

-- | @since 2.0.0
instance DerivePlutusType PTokenName where
  type DPTStrat _ = PlutusTypeNewtype

-- | @since WIP
deriving via
  DeriveDataPLiftable PTokenName Plutus.TokenName
  instance
    PLiftable PTokenName

-- | @since 3.1.0
instance PTryFrom PData PTokenName where
  type PTryFromExcess PData PTokenName = Mret PTokenName
  ptryFrom' :: forall (s :: S) (r :: PType).
Term s PData
-> ((Term s PTokenName, Reduce (PTryFromExcess PData PTokenName s))
    -> Term s r)
-> Term s r
ptryFrom' Term s PData
opq = TermCont
  s (Term s PTokenName, Reduce (PTryFromExcess PData PTokenName s))
-> ((Term s PTokenName, Reduce (PTryFromExcess PData PTokenName s))
    -> Term s r)
-> Term s r
forall (r :: PType) (s :: S) a.
TermCont s a -> (a -> Term s r) -> Term s r
runTermCont (TermCont
   s (Term s PTokenName, Reduce (PTryFromExcess PData PTokenName s))
 -> ((Term s PTokenName, Reduce (PTryFromExcess PData PTokenName s))
     -> Term s r)
 -> Term s r)
-> TermCont
     s (Term s PTokenName, Reduce (PTryFromExcess PData PTokenName s))
-> ((Term s PTokenName, Reduce (PTryFromExcess PData PTokenName s))
    -> Term s r)
-> Term s r
forall a b. (a -> b) -> a -> b
$ do
    Term s PByteString
unwrapped <- ((Term s PByteString -> Term s r) -> Term s r)
-> TermCont s (Term s PByteString)
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s PByteString -> Term s r) -> Term s r)
 -> TermCont s (Term s PByteString))
-> (Term s PByteString
    -> (Term s PByteString -> Term s r) -> Term s r)
-> Term s PByteString
-> TermCont s (Term s PByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s PByteString -> (Term s PByteString -> Term s r) -> Term s r
forall (s :: S) (a :: PType) (b :: PType).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s PByteString -> TermCont s (Term s PByteString))
-> Term s PByteString -> TermCont s (Term s PByteString)
forall a b. (a -> b) -> a -> b
$ forall (b :: PType) (a :: PType) (s :: S) (r :: PType).
PTryFrom a b =>
Term s a
-> ((Term s b, Reduce (PTryFromExcess a b s)) -> Term s r)
-> Term s r
ptryFrom @(PAsData PByteString) Term s PData
opq (Term s (PAsData PByteString), Term s PByteString)
-> Term s PByteString
(Term s (PAsData PByteString),
 Reduce (PTryFromExcess PData (PAsData PByteString) s))
-> Term s PByteString
forall a b. (a, b) -> b
snd
    ((() -> Term s r) -> Term s r) -> TermCont s ()
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((() -> Term s r) -> Term s r) -> TermCont s ())
-> ((() -> Term s r) -> Term s r) -> TermCont s ()
forall a b. (a -> b) -> a -> b
$ \() -> Term s r
f ->
      Term s PBool -> Term s r -> Term s r -> Term s r
forall (a :: PType) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif (Term s (PByteString :--> PInteger)
forall (s :: S). Term s (PByteString :--> PInteger)
plengthBS Term s (PByteString :--> PInteger)
-> Term s PByteString -> Term s PInteger
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PByteString
unwrapped Term s PInteger -> Term s PInteger -> Term s PBool
forall (s :: S). Term s PInteger -> Term s PInteger -> Term s PBool
forall (t :: PType) (s :: S).
POrd t =>
Term s t -> Term s t -> Term s PBool
#<= Term s PInteger
32) (() -> Term s r
f ()) (Term s PString -> Term s r
forall (a :: PType) (s :: S). Term s PString -> Term s a
ptraceInfoError Term s PString
"ptryFrom(TokenName): must be at most 32 bytes long")
    (Term s PTokenName, Term s PTokenName)
-> TermCont s (Term s PTokenName, Term s PTokenName)
forall a. a -> TermCont s a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Term s PData -> Term s PTokenName
forall (b :: PType) (a :: PType) (s :: S). Term s a -> Term s b
punsafeCoerce Term s PData
opq, PTokenName s -> Term s PTokenName
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PTokenName s -> Term s PTokenName)
-> (Term s PByteString -> PTokenName s)
-> Term s PByteString
-> Term s PTokenName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PDataNewtype PByteString) -> PTokenName s
forall (s :: S). Term s (PDataNewtype PByteString) -> PTokenName s
PTokenName (Term s (PDataNewtype PByteString) -> PTokenName s)
-> (Term s PByteString -> Term s (PDataNewtype PByteString))
-> Term s PByteString
-> PTokenName s
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PDataNewtype PByteString s -> Term s (PDataNewtype PByteString)
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PDataNewtype PByteString s -> Term s (PDataNewtype PByteString))
-> (Term s PByteString -> PDataNewtype PByteString s)
-> Term s PByteString
-> Term s (PDataNewtype PByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PAsData PByteString) -> PDataNewtype PByteString s
forall (a :: PType) (s :: S).
Term s (PAsData a) -> PDataNewtype a s
PDataNewtype (Term s (PAsData PByteString) -> PDataNewtype PByteString s)
-> (Term s PByteString -> Term s (PAsData PByteString))
-> Term s PByteString
-> PDataNewtype PByteString s
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s PByteString -> Term s (PAsData PByteString)
forall (a :: PType) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata (Term s PByteString -> Term s PTokenName)
-> Term s PByteString -> Term s PTokenName
forall a b. (a -> b) -> a -> b
$ Term s PByteString
unwrapped)

-- | @since 2.0.0
instance PTryFrom PData (PAsData PTokenName) where
  type PTryFromExcess PData (PAsData PTokenName) = Mret PTokenName
  ptryFrom' :: forall (s :: S) (r :: PType).
Term s PData
-> ((Term s (PAsData PTokenName),
     Reduce (PTryFromExcess PData (PAsData PTokenName) s))
    -> Term s r)
-> Term s r
ptryFrom' Term s PData
opq = TermCont
  s
  (Term s (PAsData PTokenName),
   Reduce (PTryFromExcess PData (PAsData PTokenName) s))
-> ((Term s (PAsData PTokenName),
     Reduce (PTryFromExcess PData (PAsData PTokenName) s))
    -> Term s r)
-> Term s r
forall (r :: PType) (s :: S) a.
TermCont s a -> (a -> Term s r) -> Term s r
runTermCont (TermCont
   s
   (Term s (PAsData PTokenName),
    Reduce (PTryFromExcess PData (PAsData PTokenName) s))
 -> ((Term s (PAsData PTokenName),
      Reduce (PTryFromExcess PData (PAsData PTokenName) s))
     -> Term s r)
 -> Term s r)
-> TermCont
     s
     (Term s (PAsData PTokenName),
      Reduce (PTryFromExcess PData (PAsData PTokenName) s))
-> ((Term s (PAsData PTokenName),
     Reduce (PTryFromExcess PData (PAsData PTokenName) s))
    -> Term s r)
-> Term s r
forall a b. (a -> b) -> a -> b
$ do
    Term s PByteString
unwrapped <- ((Term s PByteString -> Term s r) -> Term s r)
-> TermCont s (Term s PByteString)
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s PByteString -> Term s r) -> Term s r)
 -> TermCont s (Term s PByteString))
-> (Term s PByteString
    -> (Term s PByteString -> Term s r) -> Term s r)
-> Term s PByteString
-> TermCont s (Term s PByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s PByteString -> (Term s PByteString -> Term s r) -> Term s r
forall (s :: S) (a :: PType) (b :: PType).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s PByteString -> TermCont s (Term s PByteString))
-> Term s PByteString -> TermCont s (Term s PByteString)
forall a b. (a -> b) -> a -> b
$ forall (b :: PType) (a :: PType) (s :: S) (r :: PType).
PTryFrom a b =>
Term s a
-> ((Term s b, Reduce (PTryFromExcess a b s)) -> Term s r)
-> Term s r
ptryFrom @(PAsData PByteString) Term s PData
opq (Term s (PAsData PByteString), Term s PByteString)
-> Term s PByteString
(Term s (PAsData PByteString),
 Reduce (PTryFromExcess PData (PAsData PByteString) s))
-> Term s PByteString
forall a b. (a, b) -> b
snd
    ((() -> Term s r) -> Term s r) -> TermCont s ()
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((() -> Term s r) -> Term s r) -> TermCont s ())
-> ((() -> Term s r) -> Term s r) -> TermCont s ()
forall a b. (a -> b) -> a -> b
$ \() -> Term s r
f ->
      Term s PBool -> Term s r -> Term s r -> Term s r
forall (a :: PType) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif (Term s (PByteString :--> PInteger)
forall (s :: S). Term s (PByteString :--> PInteger)
plengthBS Term s (PByteString :--> PInteger)
-> Term s PByteString -> Term s PInteger
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PByteString
unwrapped Term s PInteger -> Term s PInteger -> Term s PBool
forall (s :: S). Term s PInteger -> Term s PInteger -> Term s PBool
forall (t :: PType) (s :: S).
POrd t =>
Term s t -> Term s t -> Term s PBool
#<= Term s PInteger
32) (() -> Term s r
f ()) (Term s PString -> Term s r
forall (a :: PType) (s :: S). Term s PString -> Term s a
ptraceInfoError Term s PString
"ptryFrom(TokenName): must be at most 32 bytes long")
    (Term s (PAsData PTokenName), Term s PTokenName)
-> TermCont s (Term s (PAsData PTokenName), Term s PTokenName)
forall a. a -> TermCont s a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Term s PData -> Term s (PAsData PTokenName)
forall (b :: PType) (a :: PType) (s :: S). Term s a -> Term s b
punsafeCoerce Term s PData
opq, PTokenName s -> Term s PTokenName
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PTokenName s -> Term s PTokenName)
-> (Term s PByteString -> PTokenName s)
-> Term s PByteString
-> Term s PTokenName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PDataNewtype PByteString) -> PTokenName s
forall (s :: S). Term s (PDataNewtype PByteString) -> PTokenName s
PTokenName (Term s (PDataNewtype PByteString) -> PTokenName s)
-> (Term s PByteString -> Term s (PDataNewtype PByteString))
-> Term s PByteString
-> PTokenName s
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PDataNewtype PByteString s -> Term s (PDataNewtype PByteString)
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PDataNewtype PByteString s -> Term s (PDataNewtype PByteString))
-> (Term s PByteString -> PDataNewtype PByteString s)
-> Term s PByteString
-> Term s (PDataNewtype PByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PAsData PByteString) -> PDataNewtype PByteString s
forall (a :: PType) (s :: S).
Term s (PAsData a) -> PDataNewtype a s
PDataNewtype (Term s (PAsData PByteString) -> PDataNewtype PByteString s)
-> (Term s PByteString -> Term s (PAsData PByteString))
-> Term s PByteString
-> PDataNewtype PByteString s
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s PByteString -> Term s (PAsData PByteString)
forall (a :: PType) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata (Term s PByteString -> Term s PTokenName)
-> Term s PByteString -> Term s PTokenName
forall a b. (a -> b) -> a -> b
$ Term s PByteString
unwrapped)

-- | @since 2.0.0
newtype PCurrencySymbol (s :: S) = PCurrencySymbol (Term s (PDataNewtype PByteString))
  deriving stock
    ( -- | @since 2.0.0
      (forall x. PCurrencySymbol s -> Rep (PCurrencySymbol s) x)
-> (forall x. Rep (PCurrencySymbol s) x -> PCurrencySymbol s)
-> Generic (PCurrencySymbol s)
forall x. Rep (PCurrencySymbol s) x -> PCurrencySymbol s
forall x. PCurrencySymbol s -> Rep (PCurrencySymbol s) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (s :: S) x. Rep (PCurrencySymbol s) x -> PCurrencySymbol s
forall (s :: S) x. PCurrencySymbol s -> Rep (PCurrencySymbol s) x
$cfrom :: forall (s :: S) x. PCurrencySymbol s -> Rep (PCurrencySymbol s) x
from :: forall x. PCurrencySymbol s -> Rep (PCurrencySymbol s) x
$cto :: forall (s :: S) x. Rep (PCurrencySymbol s) x -> PCurrencySymbol s
to :: forall x. Rep (PCurrencySymbol s) x -> PCurrencySymbol s
Generic
    )
  deriving anyclass
    ( -- | @since 2.0.0
      (forall (s :: S).
 PCurrencySymbol s -> Term s (PInner PCurrencySymbol))
-> (forall (s :: S) (b :: PType).
    Term s (PInner PCurrencySymbol)
    -> (PCurrencySymbol s -> Term s b) -> Term s b)
-> PlutusType PCurrencySymbol
forall (s :: S).
PCurrencySymbol s -> Term s (PInner PCurrencySymbol)
forall (s :: S) (b :: PType).
Term s (PInner PCurrencySymbol)
-> (PCurrencySymbol s -> Term s b) -> Term s b
forall (a :: PType).
(forall (s :: S). a s -> Term s (PInner a))
-> (forall (s :: S) (b :: PType).
    Term s (PInner a) -> (a s -> Term s b) -> Term s b)
-> PlutusType a
$cpcon' :: forall (s :: S).
PCurrencySymbol s -> Term s (PInner PCurrencySymbol)
pcon' :: forall (s :: S).
PCurrencySymbol s -> Term s (PInner PCurrencySymbol)
$cpmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PCurrencySymbol)
-> (PCurrencySymbol s -> Term s b) -> Term s b
pmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PCurrencySymbol)
-> (PCurrencySymbol s -> Term s b) -> Term s b
PlutusType
    , -- | @since 2.0.0
      (forall (s :: S).
 Term s (PAsData PCurrencySymbol) -> Term s PCurrencySymbol)
-> (forall (s :: S). Term s PCurrencySymbol -> Term s PData)
-> PIsData PCurrencySymbol
forall (s :: S).
Term s (PAsData PCurrencySymbol) -> Term s PCurrencySymbol
forall (s :: S). Term s PCurrencySymbol -> Term s PData
forall (a :: PType).
(forall (s :: S). Term s (PAsData a) -> Term s a)
-> (forall (s :: S). Term s a -> Term s PData) -> PIsData a
$cpfromDataImpl :: forall (s :: S).
Term s (PAsData PCurrencySymbol) -> Term s PCurrencySymbol
pfromDataImpl :: forall (s :: S).
Term s (PAsData PCurrencySymbol) -> Term s PCurrencySymbol
$cpdataImpl :: forall (s :: S). Term s PCurrencySymbol -> Term s PData
pdataImpl :: forall (s :: S). Term s PCurrencySymbol -> Term s PData
PIsData
    , -- | @since 2.0.0
      (forall (s :: S).
 Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool)
-> PEq PCurrencySymbol
forall (s :: S).
Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool
forall (t :: PType).
(forall (s :: S). Term s t -> Term s t -> Term s PBool) -> PEq t
$c#== :: forall (s :: S).
Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool
#== :: forall (s :: S).
Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool
PEq
    , -- | @since 2.0.0
      PEq PCurrencySymbol
PEq PCurrencySymbol =>
(forall (s :: S).
 Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool)
-> (forall (s :: S).
    Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool)
-> (forall (s :: S).
    Term s PCurrencySymbol
    -> Term s PCurrencySymbol -> Term s PCurrencySymbol)
-> (forall (s :: S).
    Term s PCurrencySymbol
    -> Term s PCurrencySymbol -> Term s PCurrencySymbol)
-> POrd PCurrencySymbol
forall (s :: S).
Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool
forall (s :: S).
Term s PCurrencySymbol
-> Term s PCurrencySymbol -> Term s PCurrencySymbol
forall (t :: PType).
PEq t =>
(forall (s :: S). Term s t -> Term s t -> Term s PBool)
-> (forall (s :: S). Term s t -> Term s t -> Term s PBool)
-> (forall (s :: S). Term s t -> Term s t -> Term s t)
-> (forall (s :: S). Term s t -> Term s t -> Term s t)
-> POrd t
$c#<= :: forall (s :: S).
Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool
#<= :: forall (s :: S).
Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool
$c#< :: forall (s :: S).
Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool
#< :: forall (s :: S).
Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool
$cpmax :: forall (s :: S).
Term s PCurrencySymbol
-> Term s PCurrencySymbol -> Term s PCurrencySymbol
pmax :: forall (s :: S).
Term s PCurrencySymbol
-> Term s PCurrencySymbol -> Term s PCurrencySymbol
$cpmin :: forall (s :: S).
Term s PCurrencySymbol
-> Term s PCurrencySymbol -> Term s PCurrencySymbol
pmin :: forall (s :: S).
Term s PCurrencySymbol
-> Term s PCurrencySymbol -> Term s PCurrencySymbol
POrd
    , -- | @since 2.0.0
      (forall (s :: S). Bool -> Term s PCurrencySymbol -> Term s PString)
-> PShow PCurrencySymbol
forall (s :: S). Bool -> Term s PCurrencySymbol -> Term s PString
forall (t :: PType).
(forall (s :: S). Bool -> Term s t -> Term s PString) -> PShow t
$cpshow' :: forall (s :: S). Bool -> Term s PCurrencySymbol -> Term s PString
pshow' :: forall (s :: S). Bool -> Term s PCurrencySymbol -> Term s PString
PShow
    )

-- | @since 2.0.0
instance DerivePlutusType PCurrencySymbol where
  type DPTStrat _ = PlutusTypeNewtype

-- | @since WIP
deriving via
  DeriveDataPLiftable PCurrencySymbol Plutus.CurrencySymbol
  instance
    PLiftable PCurrencySymbol

-- | @since 3.1.0
instance PTryFrom PData PCurrencySymbol where
  type PTryFromExcess PData PCurrencySymbol = Mret PCurrencySymbol
  ptryFrom' :: forall (s :: S) (r :: PType).
Term s PData
-> ((Term s PCurrencySymbol,
     Reduce (PTryFromExcess PData PCurrencySymbol s))
    -> Term s r)
-> Term s r
ptryFrom' Term s PData
opq = TermCont
  s
  (Term s PCurrencySymbol,
   Reduce (PTryFromExcess PData PCurrencySymbol s))
-> ((Term s PCurrencySymbol,
     Reduce (PTryFromExcess PData PCurrencySymbol s))
    -> Term s r)
-> Term s r
forall (r :: PType) (s :: S) a.
TermCont s a -> (a -> Term s r) -> Term s r
runTermCont (TermCont
   s
   (Term s PCurrencySymbol,
    Reduce (PTryFromExcess PData PCurrencySymbol s))
 -> ((Term s PCurrencySymbol,
      Reduce (PTryFromExcess PData PCurrencySymbol s))
     -> Term s r)
 -> Term s r)
-> TermCont
     s
     (Term s PCurrencySymbol,
      Reduce (PTryFromExcess PData PCurrencySymbol s))
-> ((Term s PCurrencySymbol,
     Reduce (PTryFromExcess PData PCurrencySymbol s))
    -> Term s r)
-> Term s r
forall a b. (a -> b) -> a -> b
$ do
    Term s PByteString
unwrapped <- ((Term s PByteString -> Term s r) -> Term s r)
-> TermCont s (Term s PByteString)
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s PByteString -> Term s r) -> Term s r)
 -> TermCont s (Term s PByteString))
-> (Term s PByteString
    -> (Term s PByteString -> Term s r) -> Term s r)
-> Term s PByteString
-> TermCont s (Term s PByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s PByteString -> (Term s PByteString -> Term s r) -> Term s r
forall (s :: S) (a :: PType) (b :: PType).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s PByteString -> TermCont s (Term s PByteString))
-> Term s PByteString -> TermCont s (Term s PByteString)
forall a b. (a -> b) -> a -> b
$ forall (b :: PType) (a :: PType) (s :: S) (r :: PType).
PTryFrom a b =>
Term s a
-> ((Term s b, Reduce (PTryFromExcess a b s)) -> Term s r)
-> Term s r
ptryFrom @(PAsData PByteString) Term s PData
opq (Term s (PAsData PByteString), Term s PByteString)
-> Term s PByteString
(Term s (PAsData PByteString),
 Reduce (PTryFromExcess PData (PAsData PByteString) s))
-> Term s PByteString
forall a b. (a, b) -> b
snd
    Term s PInteger
len <- ((Term s PInteger -> Term s r) -> Term s r)
-> TermCont s (Term s PInteger)
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s PInteger -> Term s r) -> Term s r)
 -> TermCont s (Term s PInteger))
-> (Term s PInteger -> (Term s PInteger -> Term s r) -> Term s r)
-> Term s PInteger
-> TermCont s (Term s PInteger)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s PInteger -> (Term s PInteger -> Term s r) -> Term s r
forall (s :: S) (a :: PType) (b :: PType).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s PInteger -> TermCont s (Term s PInteger))
-> Term s PInteger -> TermCont s (Term s PInteger)
forall a b. (a -> b) -> a -> b
$ Term s (PByteString :--> PInteger)
forall (s :: S). Term s (PByteString :--> PInteger)
plengthBS Term s (PByteString :--> PInteger)
-> Term s PByteString -> Term s PInteger
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PByteString
unwrapped
    ((() -> Term s r) -> Term s r) -> TermCont s ()
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((() -> Term s r) -> Term s r) -> TermCont s ())
-> ((() -> Term s r) -> Term s r) -> TermCont s ()
forall a b. (a -> b) -> a -> b
$ \() -> Term s r
f ->
      Term s PBool -> Term s r -> Term s r -> Term s r
forall (a :: PType) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
        (Term s PInteger
len Term s PInteger -> Term s PInteger -> Term s PBool
forall (s :: S). Term s PInteger -> Term s PInteger -> Term s PBool
forall (t :: PType) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s PInteger
0 Term s PBool -> Term s PBool -> Term s PBool
forall (s :: S). Term s PBool -> Term s PBool -> Term s PBool
#|| Term s PInteger
len Term s PInteger -> Term s PInteger -> Term s PBool
forall (s :: S). Term s PInteger -> Term s PInteger -> Term s PBool
forall (t :: PType) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s PInteger
28)
        (() -> Term s r
f ())
        (Term s PString -> Term s r
forall (a :: PType) (s :: S). Term s PString -> Term s a
ptraceInfoError Term s PString
"ptryFrom(CurrencySymbol): must be 28 bytes long or empty")
    (Term s PCurrencySymbol, Term s PCurrencySymbol)
-> TermCont s (Term s PCurrencySymbol, Term s PCurrencySymbol)
forall a. a -> TermCont s a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Term s PData -> Term s PCurrencySymbol
forall (b :: PType) (a :: PType) (s :: S). Term s a -> Term s b
punsafeCoerce Term s PData
opq, PCurrencySymbol s -> Term s PCurrencySymbol
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PCurrencySymbol s -> Term s PCurrencySymbol)
-> (Term s PByteString -> PCurrencySymbol s)
-> Term s PByteString
-> Term s PCurrencySymbol
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PDataNewtype PByteString) -> PCurrencySymbol s
forall (s :: S).
Term s (PDataNewtype PByteString) -> PCurrencySymbol s
PCurrencySymbol (Term s (PDataNewtype PByteString) -> PCurrencySymbol s)
-> (Term s PByteString -> Term s (PDataNewtype PByteString))
-> Term s PByteString
-> PCurrencySymbol s
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PDataNewtype PByteString s -> Term s (PDataNewtype PByteString)
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PDataNewtype PByteString s -> Term s (PDataNewtype PByteString))
-> (Term s PByteString -> PDataNewtype PByteString s)
-> Term s PByteString
-> Term s (PDataNewtype PByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PAsData PByteString) -> PDataNewtype PByteString s
forall (a :: PType) (s :: S).
Term s (PAsData a) -> PDataNewtype a s
PDataNewtype (Term s (PAsData PByteString) -> PDataNewtype PByteString s)
-> (Term s PByteString -> Term s (PAsData PByteString))
-> Term s PByteString
-> PDataNewtype PByteString s
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s PByteString -> Term s (PAsData PByteString)
forall (a :: PType) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata (Term s PByteString -> Term s PCurrencySymbol)
-> Term s PByteString -> Term s PCurrencySymbol
forall a b. (a -> b) -> a -> b
$ Term s PByteString
unwrapped)

-- | @since 2.0.0
instance PTryFrom PData (PAsData PCurrencySymbol) where
  type PTryFromExcess PData (PAsData PCurrencySymbol) = Mret PCurrencySymbol
  ptryFrom' :: forall (s :: S) (r :: PType).
Term s PData
-> ((Term s (PAsData PCurrencySymbol),
     Reduce (PTryFromExcess PData (PAsData PCurrencySymbol) s))
    -> Term s r)
-> Term s r
ptryFrom' Term s PData
opq = TermCont
  s
  (Term s (PAsData PCurrencySymbol),
   Reduce (PTryFromExcess PData (PAsData PCurrencySymbol) s))
-> ((Term s (PAsData PCurrencySymbol),
     Reduce (PTryFromExcess PData (PAsData PCurrencySymbol) s))
    -> Term s r)
-> Term s r
forall (r :: PType) (s :: S) a.
TermCont s a -> (a -> Term s r) -> Term s r
runTermCont (TermCont
   s
   (Term s (PAsData PCurrencySymbol),
    Reduce (PTryFromExcess PData (PAsData PCurrencySymbol) s))
 -> ((Term s (PAsData PCurrencySymbol),
      Reduce (PTryFromExcess PData (PAsData PCurrencySymbol) s))
     -> Term s r)
 -> Term s r)
-> TermCont
     s
     (Term s (PAsData PCurrencySymbol),
      Reduce (PTryFromExcess PData (PAsData PCurrencySymbol) s))
-> ((Term s (PAsData PCurrencySymbol),
     Reduce (PTryFromExcess PData (PAsData PCurrencySymbol) s))
    -> Term s r)
-> Term s r
forall a b. (a -> b) -> a -> b
$ do
    Term s PByteString
unwrapped <- ((Term s PByteString -> Term s r) -> Term s r)
-> TermCont s (Term s PByteString)
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s PByteString -> Term s r) -> Term s r)
 -> TermCont s (Term s PByteString))
-> (Term s PByteString
    -> (Term s PByteString -> Term s r) -> Term s r)
-> Term s PByteString
-> TermCont s (Term s PByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s PByteString -> (Term s PByteString -> Term s r) -> Term s r
forall (s :: S) (a :: PType) (b :: PType).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s PByteString -> TermCont s (Term s PByteString))
-> Term s PByteString -> TermCont s (Term s PByteString)
forall a b. (a -> b) -> a -> b
$ forall (b :: PType) (a :: PType) (s :: S) (r :: PType).
PTryFrom a b =>
Term s a
-> ((Term s b, Reduce (PTryFromExcess a b s)) -> Term s r)
-> Term s r
ptryFrom @(PAsData PByteString) Term s PData
opq (Term s (PAsData PByteString), Term s PByteString)
-> Term s PByteString
(Term s (PAsData PByteString),
 Reduce (PTryFromExcess PData (PAsData PByteString) s))
-> Term s PByteString
forall a b. (a, b) -> b
snd
    Term s PInteger
len <- ((Term s PInteger -> Term s r) -> Term s r)
-> TermCont s (Term s PInteger)
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s PInteger -> Term s r) -> Term s r)
 -> TermCont s (Term s PInteger))
-> (Term s PInteger -> (Term s PInteger -> Term s r) -> Term s r)
-> Term s PInteger
-> TermCont s (Term s PInteger)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s PInteger -> (Term s PInteger -> Term s r) -> Term s r
forall (s :: S) (a :: PType) (b :: PType).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s PInteger -> TermCont s (Term s PInteger))
-> Term s PInteger -> TermCont s (Term s PInteger)
forall a b. (a -> b) -> a -> b
$ Term s (PByteString :--> PInteger)
forall (s :: S). Term s (PByteString :--> PInteger)
plengthBS Term s (PByteString :--> PInteger)
-> Term s PByteString -> Term s PInteger
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PByteString
unwrapped
    ((() -> Term s r) -> Term s r) -> TermCont s ()
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((() -> Term s r) -> Term s r) -> TermCont s ())
-> ((() -> Term s r) -> Term s r) -> TermCont s ()
forall a b. (a -> b) -> a -> b
$ \() -> Term s r
f ->
      Term s PBool -> Term s r -> Term s r -> Term s r
forall (a :: PType) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif (Term s PInteger
len Term s PInteger -> Term s PInteger -> Term s PBool
forall (s :: S). Term s PInteger -> Term s PInteger -> Term s PBool
forall (t :: PType) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s PInteger
0 Term s PBool -> Term s PBool -> Term s PBool
forall (s :: S). Term s PBool -> Term s PBool -> Term s PBool
#|| Term s PInteger
len Term s PInteger -> Term s PInteger -> Term s PBool
forall (s :: S). Term s PInteger -> Term s PInteger -> Term s PBool
forall (t :: PType) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s PInteger
28) (() -> Term s r
f ()) (Term s PString -> Term s r
forall (a :: PType) (s :: S). Term s PString -> Term s a
ptraceInfoError Term s PString
"ptryFrom(CurrencySymbol): must be 28 bytes long or empty")
    (Term s (PAsData PCurrencySymbol), Term s PCurrencySymbol)
-> TermCont
     s (Term s (PAsData PCurrencySymbol), Term s PCurrencySymbol)
forall a. a -> TermCont s a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Term s PData -> Term s (PAsData PCurrencySymbol)
forall (b :: PType) (a :: PType) (s :: S). Term s a -> Term s b
punsafeCoerce Term s PData
opq, PCurrencySymbol s -> Term s PCurrencySymbol
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PCurrencySymbol s -> Term s PCurrencySymbol)
-> (Term s PByteString -> PCurrencySymbol s)
-> Term s PByteString
-> Term s PCurrencySymbol
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PDataNewtype PByteString) -> PCurrencySymbol s
forall (s :: S).
Term s (PDataNewtype PByteString) -> PCurrencySymbol s
PCurrencySymbol (Term s (PDataNewtype PByteString) -> PCurrencySymbol s)
-> (Term s PByteString -> Term s (PDataNewtype PByteString))
-> Term s PByteString
-> PCurrencySymbol s
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PDataNewtype PByteString s -> Term s (PDataNewtype PByteString)
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PDataNewtype PByteString s -> Term s (PDataNewtype PByteString))
-> (Term s PByteString -> PDataNewtype PByteString s)
-> Term s PByteString
-> Term s (PDataNewtype PByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PAsData PByteString) -> PDataNewtype PByteString s
forall (a :: PType) (s :: S).
Term s (PAsData a) -> PDataNewtype a s
PDataNewtype (Term s (PAsData PByteString) -> PDataNewtype PByteString s)
-> (Term s PByteString -> Term s (PAsData PByteString))
-> Term s PByteString
-> PDataNewtype PByteString s
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s PByteString -> Term s (PAsData PByteString)
forall (a :: PType) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata (Term s PByteString -> Term s PCurrencySymbol)
-> Term s PByteString -> Term s PCurrencySymbol
forall a b. (a -> b) -> a -> b
$ Term s PByteString
unwrapped)

-- | @since 2.0.0
data AmountGuarantees = NoGuarantees | NonZero | Positive

-- | @since 2.0.0
newtype PValue (keys :: AssocMap.KeyGuarantees) (amounts :: AmountGuarantees) (s :: S)
  = PValue (Term s (AssocMap.PMap keys PCurrencySymbol (AssocMap.PMap keys PTokenName PInteger)))
  deriving stock
    ( -- | @since 2.0.0
      (forall x. PValue keys amounts s -> Rep (PValue keys amounts s) x)
-> (forall x.
    Rep (PValue keys amounts s) x -> PValue keys amounts s)
-> Generic (PValue keys amounts s)
forall x. Rep (PValue keys amounts s) x -> PValue keys amounts s
forall x. PValue keys amounts s -> Rep (PValue keys amounts s) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S) x.
Rep (PValue keys amounts s) x -> PValue keys amounts s
forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S) x.
PValue keys amounts s -> Rep (PValue keys amounts s) x
$cfrom :: forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S) x.
PValue keys amounts s -> Rep (PValue keys amounts s) x
from :: forall x. PValue keys amounts s -> Rep (PValue keys amounts s) x
$cto :: forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S) x.
Rep (PValue keys amounts s) x -> PValue keys amounts s
to :: forall x. Rep (PValue keys amounts s) x -> PValue keys amounts s
Generic
    )
  deriving anyclass
    ( -- | @since 2.0.0
      (forall (s :: S).
 PValue keys amounts s -> Term s (PInner (PValue keys amounts)))
-> (forall (s :: S) (b :: PType).
    Term s (PInner (PValue keys amounts))
    -> (PValue keys amounts s -> Term s b) -> Term s b)
-> PlutusType (PValue keys amounts)
forall (s :: S).
PValue keys amounts s -> Term s (PInner (PValue keys amounts))
forall (s :: S) (b :: PType).
Term s (PInner (PValue keys amounts))
-> (PValue keys amounts s -> Term s b) -> Term s b
forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S).
PValue keys amounts s -> Term s (PInner (PValue keys amounts))
forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S) (b :: PType).
Term s (PInner (PValue keys amounts))
-> (PValue keys amounts s -> Term s b) -> Term s b
forall (a :: PType).
(forall (s :: S). a s -> Term s (PInner a))
-> (forall (s :: S) (b :: PType).
    Term s (PInner a) -> (a s -> Term s b) -> Term s b)
-> PlutusType a
$cpcon' :: forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S).
PValue keys amounts s -> Term s (PInner (PValue keys amounts))
pcon' :: forall (s :: S).
PValue keys amounts s -> Term s (PInner (PValue keys amounts))
$cpmatch' :: forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S) (b :: PType).
Term s (PInner (PValue keys amounts))
-> (PValue keys amounts s -> Term s b) -> Term s b
pmatch' :: forall (s :: S) (b :: PType).
Term s (PInner (PValue keys amounts))
-> (PValue keys amounts s -> Term s b) -> Term s b
PlutusType
    , -- | @since 2.0.0
      (forall (s :: S).
 Term s (PAsData (PValue keys amounts))
 -> Term s (PValue keys amounts))
-> (forall (s :: S). Term s (PValue keys amounts) -> Term s PData)
-> PIsData (PValue keys amounts)
forall (s :: S).
Term s (PAsData (PValue keys amounts))
-> Term s (PValue keys amounts)
forall (s :: S). Term s (PValue keys amounts) -> Term s PData
forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S).
Term s (PAsData (PValue keys amounts))
-> Term s (PValue keys amounts)
forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S).
Term s (PValue keys amounts) -> Term s PData
forall (a :: PType).
(forall (s :: S). Term s (PAsData a) -> Term s a)
-> (forall (s :: S). Term s a -> Term s PData) -> PIsData a
$cpfromDataImpl :: forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S).
Term s (PAsData (PValue keys amounts))
-> Term s (PValue keys amounts)
pfromDataImpl :: forall (s :: S).
Term s (PAsData (PValue keys amounts))
-> Term s (PValue keys amounts)
$cpdataImpl :: forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S).
Term s (PValue keys amounts) -> Term s PData
pdataImpl :: forall (s :: S). Term s (PValue keys amounts) -> Term s PData
PIsData
    , -- | @since 2.0.0
      (forall (s :: S).
 Bool -> Term s (PValue keys amounts) -> Term s PString)
-> PShow (PValue keys amounts)
forall (s :: S).
Bool -> Term s (PValue keys amounts) -> Term s PString
forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S).
Bool -> Term s (PValue keys amounts) -> Term s PString
forall (t :: PType).
(forall (s :: S). Bool -> Term s t -> Term s PString) -> PShow t
$cpshow' :: forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S).
Bool -> Term s (PValue keys amounts) -> Term s PString
pshow' :: forall (s :: S).
Bool -> Term s (PValue keys amounts) -> Term s PString
PShow
    )

type role PValue nominal nominal nominal

-- | @since 2.0.0
instance DerivePlutusType (PValue keys amounts) where
  type DPTStrat _ = PlutusTypeNewtype

-- | @since WIP
deriving via
  DeriveNewtypePLiftable
    (PValue 'AssocMap.Unsorted 'NoGuarantees)
    (AssocMap.PMap 'AssocMap.Unsorted PCurrencySymbol (AssocMap.PMap 'AssocMap.Unsorted PTokenName PInteger))
    Plutus.Value
  instance
    PLiftable (PValue 'AssocMap.Unsorted 'NoGuarantees)

-- | @since 2.0.0
instance PEq (PValue 'AssocMap.Sorted 'Positive) where
  Term s (PValue 'Sorted 'Positive)
a #== :: forall (s :: S).
Term s (PValue 'Sorted 'Positive)
-> Term s (PValue 'Sorted 'Positive) -> Term s PBool
#== Term s (PValue 'Sorted 'Positive)
b = Term s (PValue 'Sorted 'Positive)
-> Term s (PInner (PValue 'Sorted 'Positive))
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto Term s (PValue 'Sorted 'Positive)
a Term
  s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term s PBool
forall (s :: S).
Term
  s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term s PBool
forall (t :: PType) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s (PValue 'Sorted 'Positive)
-> Term s (PInner (PValue 'Sorted 'Positive))
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto Term s (PValue 'Sorted 'Positive)
b

-- | @since 2.0.0
instance PEq (PValue 'AssocMap.Sorted 'NonZero) where
  Term s (PValue 'Sorted 'NonZero)
a #== :: forall (s :: S).
Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NonZero) -> Term s PBool
#== Term s (PValue 'Sorted 'NonZero)
b = Term s (PValue 'Sorted 'NonZero)
-> Term s (PInner (PValue 'Sorted 'NonZero))
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto Term s (PValue 'Sorted 'NonZero)
a Term
  s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term s PBool
forall (s :: S).
Term
  s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term s PBool
forall (t :: PType) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s (PValue 'Sorted 'NonZero)
-> Term s (PInner (PValue 'Sorted 'NonZero))
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto Term s (PValue 'Sorted 'NonZero)
b

{- | Mimics the @lt@ operation on @plutus-ledger-api@'s @Value@.

@since WIP
-}
pltPositive ::
  forall (s :: S).
  Term s (PValue 'AssocMap.Sorted 'Positive) ->
  Term s (PValue 'AssocMap.Sorted 'Positive) ->
  Term s PBool
pltPositive :: forall (s :: S).
Term s (PValue 'Sorted 'Positive)
-> Term s (PValue 'Sorted 'Positive) -> Term s PBool
pltPositive Term s (PValue 'Sorted 'Positive)
t1 Term s (PValue 'Sorted 'Positive)
t2 = Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NonZero) -> Term s PBool
forall (s :: S).
Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NonZero) -> Term s PBool
pltNonZero (Term s (PValue 'Sorted 'Positive)
-> Term s (PValue 'Sorted 'NonZero)
forall (a :: AmountGuarantees) (k :: KeyGuarantees) (s :: S).
Term s (PValue k 'Positive) -> Term s (PValue k a)
pforgetPositive Term s (PValue 'Sorted 'Positive)
t1) (Term s (PValue 'Sorted 'Positive)
-> Term s (PValue 'Sorted 'NonZero)
forall (a :: AmountGuarantees) (k :: KeyGuarantees) (s :: S).
Term s (PValue k 'Positive) -> Term s (PValue k a)
pforgetPositive Term s (PValue 'Sorted 'Positive)
t2)

{- | As 'pltPositive', but for nonzero guaranteed 'PValue's instead.

@since WIP
-}
pltNonZero ::
  forall (s :: S).
  Term s (PValue 'AssocMap.Sorted 'NonZero) ->
  Term s (PValue 'AssocMap.Sorted 'NonZero) ->
  Term s PBool
pltNonZero :: forall (s :: S).
Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NonZero) -> Term s PBool
pltNonZero Term s (PValue 'Sorted 'NonZero)
t1 Term s (PValue 'Sorted 'NonZero)
t2 = Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NonZero) -> Term s PBool
forall (s :: S).
Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NonZero) -> Term s PBool
pleqNonZero Term s (PValue 'Sorted 'NonZero)
t1 Term s (PValue 'Sorted 'NonZero)
t2 Term s PBool -> Term s PBool -> Term s PBool
forall (s :: S). Term s PBool -> Term s PBool -> Term s PBool
#&& (Term s (PBool :--> PBool)
forall (s :: S). Term s (PBool :--> PBool)
pnot Term s (PBool :--> PBool) -> Term s PBool -> Term s PBool
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s (PValue 'Sorted 'NonZero)
t1 Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NonZero) -> Term s PBool
forall (s :: S).
Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NonZero) -> Term s PBool
forall (t :: PType) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s (PValue 'Sorted 'NonZero)
t2))

{- | Mimics the @leq@ operation on @plutus-ledger-api@'s @Value@.

@since WIP
-}
pleqPositive ::
  forall (s :: S).
  Term s (PValue 'AssocMap.Sorted 'Positive) ->
  Term s (PValue 'AssocMap.Sorted 'Positive) ->
  Term s PBool
pleqPositive :: forall (s :: S).
Term s (PValue 'Sorted 'Positive)
-> Term s (PValue 'Sorted 'Positive) -> Term s PBool
pleqPositive Term s (PValue 'Sorted 'Positive)
t1 Term s (PValue 'Sorted 'Positive)
t2 = Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NonZero) -> Term s PBool
forall (s :: S).
Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NonZero) -> Term s PBool
pleqNonZero (Term s (PValue 'Sorted 'Positive)
-> Term s (PValue 'Sorted 'NonZero)
forall (a :: AmountGuarantees) (k :: KeyGuarantees) (s :: S).
Term s (PValue k 'Positive) -> Term s (PValue k a)
pforgetPositive Term s (PValue 'Sorted 'Positive)
t1) (Term s (PValue 'Sorted 'Positive)
-> Term s (PValue 'Sorted 'NonZero)
forall (a :: AmountGuarantees) (k :: KeyGuarantees) (s :: S).
Term s (PValue k 'Positive) -> Term s (PValue k a)
pforgetPositive Term s (PValue 'Sorted 'Positive)
t2)

{- | As 'pletPositive', but for nonzero guaranteed 'PValue's instead.

@since WIP
-}
pleqNonZero ::
  forall (s :: S).
  Term s (PValue 'AssocMap.Sorted 'NonZero) ->
  Term s (PValue 'AssocMap.Sorted 'NonZero) ->
  Term s PBool
pleqNonZero :: forall (s :: S).
Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NonZero) -> Term s PBool
pleqNonZero Term s (PValue 'Sorted 'NonZero)
t1 Term s (PValue 'Sorted 'NonZero)
t2 =
  ClosedTerm
  (PValue 'Sorted 'NonZero :--> (PValue 'Sorted 'NonZero :--> PBool))
-> Term
     s
     (PValue 'Sorted 'NonZero :--> (PValue 'Sorted 'NonZero :--> PBool))
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (Term
  s
  ((PInteger :--> (PInteger :--> PBool))
   :--> (PValue 'Sorted 'NonZero
         :--> (PValue 'Sorted 'NonZero :--> PBool)))
forall (any0 :: AmountGuarantees) (any1 :: AmountGuarantees)
       (s :: S).
Term
  s
  ((PInteger :--> (PInteger :--> PBool))
   :--> (PValue 'Sorted any0 :--> (PValue 'Sorted any1 :--> PBool)))
pcheckBinRel Term
  s
  ((PInteger :--> (PInteger :--> PBool))
   :--> (PValue 'Sorted 'NonZero
         :--> (PValue 'Sorted 'NonZero :--> PBool)))
-> Term s (PInteger :--> (PInteger :--> PBool))
-> Term
     s
     (PValue 'Sorted 'NonZero :--> (PValue 'Sorted 'NonZero :--> PBool))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
#$ ClosedTerm (PInteger :--> (PInteger :--> PBool))
-> Term s (PInteger :--> (PInteger :--> PBool))
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm (PInteger :--> (PInteger :--> PBool))
 -> Term s (PInteger :--> (PInteger :--> PBool)))
-> ClosedTerm (PInteger :--> (PInteger :--> PBool))
-> Term s (PInteger :--> (PInteger :--> PBool))
forall a b. (a -> b) -> a -> b
$ (Term s PInteger -> Term s PInteger -> Term s PBool)
-> Term s (PInteger :--> (PInteger :--> PBool))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s PInteger -> Term s PBool)
-> Term s (c :--> (PInteger :--> PBool))
plam Term s PInteger -> Term s PInteger -> Term s PBool
forall (s :: S). Term s PInteger -> Term s PInteger -> Term s PBool
forall (t :: PType) (s :: S).
POrd t =>
Term s t -> Term s t -> Term s PBool
(#<=)) Term
  s
  (PValue 'Sorted 'NonZero :--> (PValue 'Sorted 'NonZero :--> PBool))
-> Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NonZero :--> PBool)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PValue 'Sorted 'NonZero)
t1 Term s (PValue 'Sorted 'NonZero :--> PBool)
-> Term s (PValue 'Sorted 'NonZero) -> Term s PBool
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PValue 'Sorted 'NonZero)
t2

-- | @since 2.0.0
instance PEq (PValue 'AssocMap.Sorted 'NoGuarantees) where
  Term s (PValue 'Sorted 'NoGuarantees)
a #== :: forall (s :: S).
Term s (PValue 'Sorted 'NoGuarantees)
-> Term s (PValue 'Sorted 'NoGuarantees) -> Term s PBool
#== Term s (PValue 'Sorted 'NoGuarantees)
b =
    Term
  s
  ((PMap 'Sorted PTokenName PInteger :--> PBool)
   :--> (PMap
           'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
         :--> PBool))
forall (any :: KeyGuarantees) (k :: PType) (v :: PType) (s :: S).
PIsData v =>
Term s ((v :--> PBool) :--> (PMap any k v :--> PBool))
AssocMap.pall
      # (AssocMap.pall # plam (#== 0))
      -- While '(-)' is not commutative, we don't need that property here.
      -- TODO benchmark with '(==)'
      # pto (punionResolvingCollisionsWith AssocMap.Commutative # plam (-) # a # b)

-- | @since 2.0.0
instance Semigroup (Term s (PValue 'AssocMap.Sorted 'Positive)) where
  Term s (PValue 'Sorted 'Positive)
a <> :: Term s (PValue 'Sorted 'Positive)
-> Term s (PValue 'Sorted 'Positive)
-> Term s (PValue 'Sorted 'Positive)
<> Term s (PValue 'Sorted 'Positive)
b =
    Term s (PInner (PValue 'Sorted 'Positive))
-> Term s (PValue 'Sorted 'Positive)
forall (s :: S) (a :: PType). Term s (PInner a) -> Term s a
punsafeDowncast (Term s (PValue 'Sorted 'NoGuarantees)
-> Term s (PInner (PValue 'Sorted 'NoGuarantees))
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto (Term s (PValue 'Sorted 'NoGuarantees)
 -> Term s (PInner (PValue 'Sorted 'NoGuarantees)))
-> Term s (PValue 'Sorted 'NoGuarantees)
-> Term s (PInner (PValue 'Sorted 'NoGuarantees))
forall a b. (a -> b) -> a -> b
$ Commutativity
-> Term
     s
     ((PInteger :--> (PInteger :--> PInteger))
      :--> (PValue 'Sorted 'Positive
            :--> (PValue 'Sorted 'Positive :--> PValue 'Sorted 'NoGuarantees)))
forall (any0 :: AmountGuarantees) (any1 :: AmountGuarantees)
       (s :: S).
Commutativity
-> Term
     s
     ((PInteger :--> (PInteger :--> PInteger))
      :--> (PValue 'Sorted any0
            :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
punionResolvingCollisionsWith Commutativity
AssocMap.Commutative Term
  s
  ((PInteger :--> (PInteger :--> PInteger))
   :--> (PValue 'Sorted 'Positive
         :--> (PValue 'Sorted 'Positive :--> PValue 'Sorted 'NoGuarantees)))
-> Term s (PInteger :--> (PInteger :--> PInteger))
-> Term
     s
     (PValue 'Sorted 'Positive
      :--> (PValue 'Sorted 'Positive :--> PValue 'Sorted 'NoGuarantees))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s PInteger -> Term s PInteger -> Term s PInteger)
-> Term s (PInteger :--> (PInteger :--> PInteger))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s PInteger -> Term s PInteger)
-> Term s (c :--> (PInteger :--> PInteger))
plam Term s PInteger -> Term s PInteger -> Term s PInteger
forall a. Num a => a -> a -> a
(+) Term
  s
  (PValue 'Sorted 'Positive
   :--> (PValue 'Sorted 'Positive :--> PValue 'Sorted 'NoGuarantees))
-> Term s (PValue 'Sorted 'Positive)
-> Term
     s (PValue 'Sorted 'Positive :--> PValue 'Sorted 'NoGuarantees)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PValue 'Sorted 'Positive)
a Term s (PValue 'Sorted 'Positive :--> PValue 'Sorted 'NoGuarantees)
-> Term s (PValue 'Sorted 'Positive)
-> Term s (PValue 'Sorted 'NoGuarantees)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PValue 'Sorted 'Positive)
b)

-- | @since 2.0.0
instance PlutusTx.Semigroup (Term s (PValue 'AssocMap.Sorted 'Positive)) where
  Term s (PValue 'Sorted 'Positive)
a <> :: Term s (PValue 'Sorted 'Positive)
-> Term s (PValue 'Sorted 'Positive)
-> Term s (PValue 'Sorted 'Positive)
<> Term s (PValue 'Sorted 'Positive)
b =
    Term s (PInner (PValue 'Sorted 'Positive))
-> Term s (PValue 'Sorted 'Positive)
forall (s :: S) (a :: PType). Term s (PInner a) -> Term s a
punsafeDowncast (Term s (PValue 'Sorted 'NoGuarantees)
-> Term s (PInner (PValue 'Sorted 'NoGuarantees))
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto (Term s (PValue 'Sorted 'NoGuarantees)
 -> Term s (PInner (PValue 'Sorted 'NoGuarantees)))
-> Term s (PValue 'Sorted 'NoGuarantees)
-> Term s (PInner (PValue 'Sorted 'NoGuarantees))
forall a b. (a -> b) -> a -> b
$ Commutativity
-> Term
     s
     ((PInteger :--> (PInteger :--> PInteger))
      :--> (PValue 'Sorted 'Positive
            :--> (PValue 'Sorted 'Positive :--> PValue 'Sorted 'NoGuarantees)))
forall (any0 :: AmountGuarantees) (any1 :: AmountGuarantees)
       (s :: S).
Commutativity
-> Term
     s
     ((PInteger :--> (PInteger :--> PInteger))
      :--> (PValue 'Sorted any0
            :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
punionResolvingCollisionsWith Commutativity
AssocMap.Commutative Term
  s
  ((PInteger :--> (PInteger :--> PInteger))
   :--> (PValue 'Sorted 'Positive
         :--> (PValue 'Sorted 'Positive :--> PValue 'Sorted 'NoGuarantees)))
-> Term s (PInteger :--> (PInteger :--> PInteger))
-> Term
     s
     (PValue 'Sorted 'Positive
      :--> (PValue 'Sorted 'Positive :--> PValue 'Sorted 'NoGuarantees))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s PInteger -> Term s PInteger -> Term s PInteger)
-> Term s (PInteger :--> (PInteger :--> PInteger))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s PInteger -> Term s PInteger)
-> Term s (c :--> (PInteger :--> PInteger))
plam Term s PInteger -> Term s PInteger -> Term s PInteger
forall a. Num a => a -> a -> a
(+) Term
  s
  (PValue 'Sorted 'Positive
   :--> (PValue 'Sorted 'Positive :--> PValue 'Sorted 'NoGuarantees))
-> Term s (PValue 'Sorted 'Positive)
-> Term
     s (PValue 'Sorted 'Positive :--> PValue 'Sorted 'NoGuarantees)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PValue 'Sorted 'Positive)
a Term s (PValue 'Sorted 'Positive :--> PValue 'Sorted 'NoGuarantees)
-> Term s (PValue 'Sorted 'Positive)
-> Term s (PValue 'Sorted 'NoGuarantees)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PValue 'Sorted 'Positive)
b)

-- | @since 2.0.0
instance Semigroup (Term s (PValue 'AssocMap.Sorted 'NonZero)) where
  Term s (PValue 'Sorted 'NonZero)
a <> :: Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NonZero)
<> Term s (PValue 'Sorted 'NonZero)
b =
    Term s (PValue 'Sorted 'NoGuarantees :--> PValue 'Sorted 'NonZero)
forall (any :: AmountGuarantees) (s :: S).
Term s (PValue 'Sorted any :--> PValue 'Sorted 'NonZero)
pnormalize Term s (PValue 'Sorted 'NoGuarantees :--> PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NoGuarantees)
-> Term s (PValue 'Sorted 'NonZero)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
#$ Commutativity
-> Term
     s
     ((PInteger :--> (PInteger :--> PInteger))
      :--> (PValue 'Sorted 'NonZero
            :--> (PValue 'Sorted 'NonZero :--> PValue 'Sorted 'NoGuarantees)))
forall (any0 :: AmountGuarantees) (any1 :: AmountGuarantees)
       (s :: S).
Commutativity
-> Term
     s
     ((PInteger :--> (PInteger :--> PInteger))
      :--> (PValue 'Sorted any0
            :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
punionResolvingCollisionsWith Commutativity
AssocMap.Commutative Term
  s
  ((PInteger :--> (PInteger :--> PInteger))
   :--> (PValue 'Sorted 'NonZero
         :--> (PValue 'Sorted 'NonZero :--> PValue 'Sorted 'NoGuarantees)))
-> Term s (PInteger :--> (PInteger :--> PInteger))
-> Term
     s
     (PValue 'Sorted 'NonZero
      :--> (PValue 'Sorted 'NonZero :--> PValue 'Sorted 'NoGuarantees))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s PInteger -> Term s PInteger -> Term s PInteger)
-> Term s (PInteger :--> (PInteger :--> PInteger))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s PInteger -> Term s PInteger)
-> Term s (c :--> (PInteger :--> PInteger))
plam Term s PInteger -> Term s PInteger -> Term s PInteger
forall a. Num a => a -> a -> a
(+) Term
  s
  (PValue 'Sorted 'NonZero
   :--> (PValue 'Sorted 'NonZero :--> PValue 'Sorted 'NoGuarantees))
-> Term s (PValue 'Sorted 'NonZero)
-> Term
     s (PValue 'Sorted 'NonZero :--> PValue 'Sorted 'NoGuarantees)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PValue 'Sorted 'NonZero)
a Term s (PValue 'Sorted 'NonZero :--> PValue 'Sorted 'NoGuarantees)
-> Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NoGuarantees)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PValue 'Sorted 'NonZero)
b

-- | @since 2.0.0
instance PlutusTx.Semigroup (Term s (PValue 'AssocMap.Sorted 'NonZero)) where
  Term s (PValue 'Sorted 'NonZero)
a <> :: Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NonZero)
<> Term s (PValue 'Sorted 'NonZero)
b =
    Term s (PValue 'Sorted 'NoGuarantees :--> PValue 'Sorted 'NonZero)
forall (any :: AmountGuarantees) (s :: S).
Term s (PValue 'Sorted any :--> PValue 'Sorted 'NonZero)
pnormalize Term s (PValue 'Sorted 'NoGuarantees :--> PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NoGuarantees)
-> Term s (PValue 'Sorted 'NonZero)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
#$ Commutativity
-> Term
     s
     ((PInteger :--> (PInteger :--> PInteger))
      :--> (PValue 'Sorted 'NonZero
            :--> (PValue 'Sorted 'NonZero :--> PValue 'Sorted 'NoGuarantees)))
forall (any0 :: AmountGuarantees) (any1 :: AmountGuarantees)
       (s :: S).
Commutativity
-> Term
     s
     ((PInteger :--> (PInteger :--> PInteger))
      :--> (PValue 'Sorted any0
            :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
punionResolvingCollisionsWith Commutativity
AssocMap.Commutative Term
  s
  ((PInteger :--> (PInteger :--> PInteger))
   :--> (PValue 'Sorted 'NonZero
         :--> (PValue 'Sorted 'NonZero :--> PValue 'Sorted 'NoGuarantees)))
-> Term s (PInteger :--> (PInteger :--> PInteger))
-> Term
     s
     (PValue 'Sorted 'NonZero
      :--> (PValue 'Sorted 'NonZero :--> PValue 'Sorted 'NoGuarantees))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s PInteger -> Term s PInteger -> Term s PInteger)
-> Term s (PInteger :--> (PInteger :--> PInteger))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s PInteger -> Term s PInteger)
-> Term s (c :--> (PInteger :--> PInteger))
plam Term s PInteger -> Term s PInteger -> Term s PInteger
forall a. Num a => a -> a -> a
(+) Term
  s
  (PValue 'Sorted 'NonZero
   :--> (PValue 'Sorted 'NonZero :--> PValue 'Sorted 'NoGuarantees))
-> Term s (PValue 'Sorted 'NonZero)
-> Term
     s (PValue 'Sorted 'NonZero :--> PValue 'Sorted 'NoGuarantees)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PValue 'Sorted 'NonZero)
a Term s (PValue 'Sorted 'NonZero :--> PValue 'Sorted 'NoGuarantees)
-> Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NoGuarantees)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PValue 'Sorted 'NonZero)
b

-- | @since 2.0.0
instance Semigroup (Term s (PValue 'AssocMap.Sorted 'NoGuarantees)) where
  Term s (PValue 'Sorted 'NoGuarantees)
a <> :: Term s (PValue 'Sorted 'NoGuarantees)
-> Term s (PValue 'Sorted 'NoGuarantees)
-> Term s (PValue 'Sorted 'NoGuarantees)
<> Term s (PValue 'Sorted 'NoGuarantees)
b =
    Commutativity
-> Term
     s
     ((PInteger :--> (PInteger :--> PInteger))
      :--> (PValue 'Sorted 'NoGuarantees
            :--> (PValue 'Sorted 'NoGuarantees
                  :--> PValue 'Sorted 'NoGuarantees)))
forall (any0 :: AmountGuarantees) (any1 :: AmountGuarantees)
       (s :: S).
Commutativity
-> Term
     s
     ((PInteger :--> (PInteger :--> PInteger))
      :--> (PValue 'Sorted any0
            :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
punionResolvingCollisionsWith Commutativity
AssocMap.Commutative Term
  s
  ((PInteger :--> (PInteger :--> PInteger))
   :--> (PValue 'Sorted 'NoGuarantees
         :--> (PValue 'Sorted 'NoGuarantees
               :--> PValue 'Sorted 'NoGuarantees)))
-> Term s (PInteger :--> (PInteger :--> PInteger))
-> Term
     s
     (PValue 'Sorted 'NoGuarantees
      :--> (PValue 'Sorted 'NoGuarantees
            :--> PValue 'Sorted 'NoGuarantees))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s PInteger -> Term s PInteger -> Term s PInteger)
-> Term s (PInteger :--> (PInteger :--> PInteger))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s PInteger -> Term s PInteger)
-> Term s (c :--> (PInteger :--> PInteger))
plam Term s PInteger -> Term s PInteger -> Term s PInteger
forall a. Num a => a -> a -> a
(+) Term
  s
  (PValue 'Sorted 'NoGuarantees
   :--> (PValue 'Sorted 'NoGuarantees
         :--> PValue 'Sorted 'NoGuarantees))
-> Term s (PValue 'Sorted 'NoGuarantees)
-> Term
     s (PValue 'Sorted 'NoGuarantees :--> PValue 'Sorted 'NoGuarantees)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PValue 'Sorted 'NoGuarantees)
a Term
  s (PValue 'Sorted 'NoGuarantees :--> PValue 'Sorted 'NoGuarantees)
-> Term s (PValue 'Sorted 'NoGuarantees)
-> Term s (PValue 'Sorted 'NoGuarantees)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PValue 'Sorted 'NoGuarantees)
b

-- | @since 2.0.0
instance PlutusTx.Semigroup (Term s (PValue 'AssocMap.Sorted 'NoGuarantees)) where
  Term s (PValue 'Sorted 'NoGuarantees)
a <> :: Term s (PValue 'Sorted 'NoGuarantees)
-> Term s (PValue 'Sorted 'NoGuarantees)
-> Term s (PValue 'Sorted 'NoGuarantees)
<> Term s (PValue 'Sorted 'NoGuarantees)
b =
    Commutativity
-> Term
     s
     ((PInteger :--> (PInteger :--> PInteger))
      :--> (PValue 'Sorted 'NoGuarantees
            :--> (PValue 'Sorted 'NoGuarantees
                  :--> PValue 'Sorted 'NoGuarantees)))
forall (any0 :: AmountGuarantees) (any1 :: AmountGuarantees)
       (s :: S).
Commutativity
-> Term
     s
     ((PInteger :--> (PInteger :--> PInteger))
      :--> (PValue 'Sorted any0
            :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
punionResolvingCollisionsWith Commutativity
AssocMap.Commutative Term
  s
  ((PInteger :--> (PInteger :--> PInteger))
   :--> (PValue 'Sorted 'NoGuarantees
         :--> (PValue 'Sorted 'NoGuarantees
               :--> PValue 'Sorted 'NoGuarantees)))
-> Term s (PInteger :--> (PInteger :--> PInteger))
-> Term
     s
     (PValue 'Sorted 'NoGuarantees
      :--> (PValue 'Sorted 'NoGuarantees
            :--> PValue 'Sorted 'NoGuarantees))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s PInteger -> Term s PInteger -> Term s PInteger)
-> Term s (PInteger :--> (PInteger :--> PInteger))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s PInteger -> Term s PInteger)
-> Term s (c :--> (PInteger :--> PInteger))
plam Term s PInteger -> Term s PInteger -> Term s PInteger
forall a. Num a => a -> a -> a
(+) Term
  s
  (PValue 'Sorted 'NoGuarantees
   :--> (PValue 'Sorted 'NoGuarantees
         :--> PValue 'Sorted 'NoGuarantees))
-> Term s (PValue 'Sorted 'NoGuarantees)
-> Term
     s (PValue 'Sorted 'NoGuarantees :--> PValue 'Sorted 'NoGuarantees)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PValue 'Sorted 'NoGuarantees)
a Term
  s (PValue 'Sorted 'NoGuarantees :--> PValue 'Sorted 'NoGuarantees)
-> Term s (PValue 'Sorted 'NoGuarantees)
-> Term s (PValue 'Sorted 'NoGuarantees)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PValue 'Sorted 'NoGuarantees)
b

-- | @since 2.0.0
instance
  Semigroup (Term s (PValue 'AssocMap.Sorted normalization)) =>
  Monoid (Term s (PValue 'AssocMap.Sorted normalization))
  where
  mempty :: Term s (PValue 'Sorted normalization)
mempty = PValue 'Sorted normalization s
-> Term s (PValue 'Sorted normalization)
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (Term
  s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> PValue 'Sorted normalization s
forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S).
Term s (PMap keys PCurrencySymbol (PMap keys PTokenName PInteger))
-> PValue keys amounts s
PValue Term
  s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
forall (s :: S) (k :: PType) (v :: PType).
Term s (PMap 'Sorted k v)
AssocMap.pempty)

-- | @since 2.0.0
instance
  PlutusTx.Semigroup (Term s (PValue 'AssocMap.Sorted normalization)) =>
  PlutusTx.Monoid (Term s (PValue 'AssocMap.Sorted normalization))
  where
  mempty :: Term s (PValue 'Sorted normalization)
mempty = PValue 'Sorted normalization s
-> Term s (PValue 'Sorted normalization)
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (Term
  s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> PValue 'Sorted normalization s
forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S).
Term s (PMap keys PCurrencySymbol (PMap keys PTokenName PInteger))
-> PValue keys amounts s
PValue Term
  s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
forall (s :: S) (k :: PType) (v :: PType).
Term s (PMap 'Sorted k v)
AssocMap.pempty)

-- | @since 2.0.0
instance
  PlutusTx.Semigroup (Term s (PValue 'AssocMap.Sorted 'NoGuarantees)) =>
  PlutusTx.Group (Term s (PValue 'AssocMap.Sorted 'NoGuarantees))
  where
  inv :: Term s (PValue 'Sorted 'NoGuarantees)
-> Term s (PValue 'Sorted 'NoGuarantees)
inv Term s (PValue 'Sorted 'NoGuarantees)
a = Term
  s
  ((PInteger :--> PInteger)
   :--> (PValue 'Sorted 'NoGuarantees
         :--> PValue 'Sorted 'NoGuarantees))
forall (k :: KeyGuarantees) (a :: AmountGuarantees) (s :: S).
Term
  s
  ((PInteger :--> PInteger)
   :--> (PValue k a :--> PValue k 'NoGuarantees))
pmapAmounts Term
  s
  ((PInteger :--> PInteger)
   :--> (PValue 'Sorted 'NoGuarantees
         :--> PValue 'Sorted 'NoGuarantees))
-> Term s (PInteger :--> PInteger)
-> Term
     s (PValue 'Sorted 'NoGuarantees :--> PValue 'Sorted 'NoGuarantees)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s PInteger -> Term s PInteger)
-> Term s (PInteger :--> PInteger)
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s PInteger) -> Term s (c :--> PInteger)
plam Term s PInteger -> Term s PInteger
forall a. Num a => a -> a
negate Term
  s (PValue 'Sorted 'NoGuarantees :--> PValue 'Sorted 'NoGuarantees)
-> Term s (PValue 'Sorted 'NoGuarantees)
-> Term s (PValue 'Sorted 'NoGuarantees)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PValue 'Sorted 'NoGuarantees)
a

-- | @since 2.0.0
instance
  PlutusTx.Semigroup (Term s (PValue 'AssocMap.Sorted 'NonZero)) =>
  PlutusTx.Group (Term s (PValue 'AssocMap.Sorted 'NonZero))
  where
  inv :: Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NonZero)
inv Term s (PValue 'Sorted 'NonZero)
a =
    Term s (PValue 'Sorted 'NoGuarantees)
-> Term s (PValue 'Sorted 'NonZero)
forall (b :: PType) (a :: PType) (s :: S). Term s a -> Term s b
punsafeCoerce (Term s (PValue 'Sorted 'NoGuarantees)
 -> Term s (PValue 'Sorted 'NonZero))
-> Term s (PValue 'Sorted 'NoGuarantees)
-> Term s (PValue 'Sorted 'NonZero)
forall a b. (a -> b) -> a -> b
$ Term s (PValue 'Sorted 'NoGuarantees)
-> Term s (PValue 'Sorted 'NoGuarantees)
forall a. Group a => a -> a
PlutusTx.inv (Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NoGuarantees)
forall (b :: PType) (a :: PType) (s :: S). Term s a -> Term s b
punsafeCoerce Term s (PValue 'Sorted 'NonZero)
a :: Term s (PValue 'AssocMap.Sorted 'NoGuarantees))

-- | @since 2.0.0
instance PTryFrom PData (PAsData (PValue 'AssocMap.Unsorted 'NoGuarantees))

-- | @since 2.0.0
instance PTryFrom PData (PAsData (PValue 'AssocMap.Sorted 'NoGuarantees))

-- | @since 2.0.0
instance PTryFrom PData (PAsData (PValue 'AssocMap.Sorted 'Positive)) where
  type PTryFromExcess PData (PAsData (PValue 'AssocMap.Sorted 'Positive)) = Mret (PValue 'AssocMap.Sorted 'Positive)
  ptryFrom' :: forall (s :: S) (r :: PType).
Term s PData
-> ((Term s (PAsData (PValue 'Sorted 'Positive)),
     Reduce
       (PTryFromExcess PData (PAsData (PValue 'Sorted 'Positive)) s))
    -> Term s r)
-> Term s r
ptryFrom' Term s PData
opq = TermCont
  s
  (Term s (PAsData (PValue 'Sorted 'Positive)),
   Reduce
     (PTryFromExcess PData (PAsData (PValue 'Sorted 'Positive)) s))
-> ((Term s (PAsData (PValue 'Sorted 'Positive)),
     Reduce
       (PTryFromExcess PData (PAsData (PValue 'Sorted 'Positive)) s))
    -> Term s r)
-> Term s r
forall (r :: PType) (s :: S) a.
TermCont s a -> (a -> Term s r) -> Term s r
runTermCont (TermCont
   s
   (Term s (PAsData (PValue 'Sorted 'Positive)),
    Reduce
      (PTryFromExcess PData (PAsData (PValue 'Sorted 'Positive)) s))
 -> ((Term s (PAsData (PValue 'Sorted 'Positive)),
      Reduce
        (PTryFromExcess PData (PAsData (PValue 'Sorted 'Positive)) s))
     -> Term s r)
 -> Term s r)
-> TermCont
     s
     (Term s (PAsData (PValue 'Sorted 'Positive)),
      Reduce
        (PTryFromExcess PData (PAsData (PValue 'Sorted 'Positive)) s))
-> ((Term s (PAsData (PValue 'Sorted 'Positive)),
     Reduce
       (PTryFromExcess PData (PAsData (PValue 'Sorted 'Positive)) s))
    -> Term s r)
-> Term s r
forall a b. (a -> b) -> a -> b
$ do
    (Term s (PAsData (PValue 'Sorted 'NoGuarantees))
opq', Term
  s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
_) <- (((Term s (PAsData (PValue 'Sorted 'NoGuarantees)),
   Term
     s
     (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
  -> Term s r)
 -> Term s r)
-> TermCont
     s
     (Term s (PAsData (PValue 'Sorted 'NoGuarantees)),
      Term
        s
        (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont ((((Term s (PAsData (PValue 'Sorted 'NoGuarantees)),
    Term
      s
      (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
   -> Term s r)
  -> Term s r)
 -> TermCont
      s
      (Term s (PAsData (PValue 'Sorted 'NoGuarantees)),
       Term
         s
         (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))))
-> (((Term s (PAsData (PValue 'Sorted 'NoGuarantees)),
      Term
        s
        (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
     -> Term s r)
    -> Term s r)
-> TermCont
     s
     (Term s (PAsData (PValue 'Sorted 'NoGuarantees)),
      Term
        s
        (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
forall a b. (a -> b) -> a -> b
$ forall (b :: PType) (a :: PType) (s :: S) (r :: PType).
PTryFrom a b =>
Term s a
-> ((Term s b, Reduce (PTryFromExcess a b s)) -> Term s r)
-> Term s r
ptryFrom @(PAsData (PValue 'AssocMap.Sorted 'NoGuarantees)) Term s PData
opq
    Term s (PValue 'Sorted 'Positive)
unwrapped <- ((Term s (PValue 'Sorted 'Positive) -> Term s r) -> Term s r)
-> TermCont s (Term s (PValue 'Sorted 'Positive))
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s (PValue 'Sorted 'Positive) -> Term s r) -> Term s r)
 -> TermCont s (Term s (PValue 'Sorted 'Positive)))
-> (Term s (PAsData (PValue 'Sorted 'NoGuarantees))
    -> (Term s (PValue 'Sorted 'Positive) -> Term s r) -> Term s r)
-> Term s (PAsData (PValue 'Sorted 'NoGuarantees))
-> TermCont s (Term s (PValue 'Sorted 'Positive))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PValue 'Sorted 'Positive)
-> (Term s (PValue 'Sorted 'Positive) -> Term s r) -> Term s r
forall (s :: S) (a :: PType) (b :: PType).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s (PValue 'Sorted 'Positive)
 -> (Term s (PValue 'Sorted 'Positive) -> Term s r) -> Term s r)
-> (Term s (PAsData (PValue 'Sorted 'NoGuarantees))
    -> Term s (PValue 'Sorted 'Positive))
-> Term s (PAsData (PValue 'Sorted 'NoGuarantees))
-> (Term s (PValue 'Sorted 'Positive) -> Term s r)
-> Term s r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PValue 'Sorted 'NoGuarantees :--> PValue 'Sorted 'Positive)
-> Term s (PValue 'Sorted 'NoGuarantees)
-> Term s (PValue 'Sorted 'Positive)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
papp Term s (PValue 'Sorted 'NoGuarantees :--> PValue 'Sorted 'Positive)
forall (kg :: KeyGuarantees) (ag :: AmountGuarantees) (s :: S).
Term s (PValue kg ag :--> PValue kg 'Positive)
passertPositive (Term s (PValue 'Sorted 'NoGuarantees)
 -> Term s (PValue 'Sorted 'Positive))
-> (Term s (PAsData (PValue 'Sorted 'NoGuarantees))
    -> Term s (PValue 'Sorted 'NoGuarantees))
-> Term s (PAsData (PValue 'Sorted 'NoGuarantees))
-> Term s (PValue 'Sorted 'Positive)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PAsData (PValue 'Sorted 'NoGuarantees))
-> Term s (PValue 'Sorted 'NoGuarantees)
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData (PValue 'Sorted 'NoGuarantees))
 -> TermCont s (Term s (PValue 'Sorted 'Positive)))
-> Term s (PAsData (PValue 'Sorted 'NoGuarantees))
-> TermCont s (Term s (PValue 'Sorted 'Positive))
forall a b. (a -> b) -> a -> b
$ Term s (PAsData (PValue 'Sorted 'NoGuarantees))
opq'
    (Term s (PAsData (PValue 'Sorted 'Positive)),
 Term s (PValue 'Sorted 'Positive))
-> TermCont
     s
     (Term s (PAsData (PValue 'Sorted 'Positive)),
      Term s (PValue 'Sorted 'Positive))
forall a. a -> TermCont s a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Term s PData -> Term s (PAsData (PValue 'Sorted 'Positive))
forall (b :: PType) (a :: PType) (s :: S). Term s a -> Term s b
punsafeCoerce Term s PData
opq, Term s (PValue 'Sorted 'Positive)
unwrapped)

-- | @since 2.0.0
instance PTryFrom PData (PAsData (PValue 'AssocMap.Unsorted 'Positive)) where
  type PTryFromExcess PData (PAsData (PValue 'AssocMap.Unsorted 'Positive)) = Mret (PValue 'AssocMap.Unsorted 'Positive)
  ptryFrom' :: forall (s :: S) (r :: PType).
Term s PData
-> ((Term s (PAsData (PValue 'Unsorted 'Positive)),
     Reduce
       (PTryFromExcess PData (PAsData (PValue 'Unsorted 'Positive)) s))
    -> Term s r)
-> Term s r
ptryFrom' Term s PData
opq = TermCont
  s
  (Term s (PAsData (PValue 'Unsorted 'Positive)),
   Reduce
     (PTryFromExcess PData (PAsData (PValue 'Unsorted 'Positive)) s))
-> ((Term s (PAsData (PValue 'Unsorted 'Positive)),
     Reduce
       (PTryFromExcess PData (PAsData (PValue 'Unsorted 'Positive)) s))
    -> Term s r)
-> Term s r
forall (r :: PType) (s :: S) a.
TermCont s a -> (a -> Term s r) -> Term s r
runTermCont (TermCont
   s
   (Term s (PAsData (PValue 'Unsorted 'Positive)),
    Reduce
      (PTryFromExcess PData (PAsData (PValue 'Unsorted 'Positive)) s))
 -> ((Term s (PAsData (PValue 'Unsorted 'Positive)),
      Reduce
        (PTryFromExcess PData (PAsData (PValue 'Unsorted 'Positive)) s))
     -> Term s r)
 -> Term s r)
-> TermCont
     s
     (Term s (PAsData (PValue 'Unsorted 'Positive)),
      Reduce
        (PTryFromExcess PData (PAsData (PValue 'Unsorted 'Positive)) s))
-> ((Term s (PAsData (PValue 'Unsorted 'Positive)),
     Reduce
       (PTryFromExcess PData (PAsData (PValue 'Unsorted 'Positive)) s))
    -> Term s r)
-> Term s r
forall a b. (a -> b) -> a -> b
$ do
    (Term s (PAsData (PValue 'Unsorted 'NoGuarantees))
opq', Term
  s
  (PMap
     'Unsorted PCurrencySymbol (PMap 'Unsorted PTokenName PInteger))
_) <- (((Term s (PAsData (PValue 'Unsorted 'NoGuarantees)),
   Term
     s
     (PMap
        'Unsorted PCurrencySymbol (PMap 'Unsorted PTokenName PInteger)))
  -> Term s r)
 -> Term s r)
-> TermCont
     s
     (Term s (PAsData (PValue 'Unsorted 'NoGuarantees)),
      Term
        s
        (PMap
           'Unsorted PCurrencySymbol (PMap 'Unsorted PTokenName PInteger)))
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont ((((Term s (PAsData (PValue 'Unsorted 'NoGuarantees)),
    Term
      s
      (PMap
         'Unsorted PCurrencySymbol (PMap 'Unsorted PTokenName PInteger)))
   -> Term s r)
  -> Term s r)
 -> TermCont
      s
      (Term s (PAsData (PValue 'Unsorted 'NoGuarantees)),
       Term
         s
         (PMap
            'Unsorted PCurrencySymbol (PMap 'Unsorted PTokenName PInteger))))
-> (((Term s (PAsData (PValue 'Unsorted 'NoGuarantees)),
      Term
        s
        (PMap
           'Unsorted PCurrencySymbol (PMap 'Unsorted PTokenName PInteger)))
     -> Term s r)
    -> Term s r)
-> TermCont
     s
     (Term s (PAsData (PValue 'Unsorted 'NoGuarantees)),
      Term
        s
        (PMap
           'Unsorted PCurrencySymbol (PMap 'Unsorted PTokenName PInteger)))
forall a b. (a -> b) -> a -> b
$ forall (b :: PType) (a :: PType) (s :: S) (r :: PType).
PTryFrom a b =>
Term s a
-> ((Term s b, Reduce (PTryFromExcess a b s)) -> Term s r)
-> Term s r
ptryFrom @(PAsData (PValue 'AssocMap.Unsorted 'NoGuarantees)) Term s PData
opq
    Term s (PValue 'Unsorted 'Positive)
unwrapped <- ((Term s (PValue 'Unsorted 'Positive) -> Term s r) -> Term s r)
-> TermCont s (Term s (PValue 'Unsorted 'Positive))
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s (PValue 'Unsorted 'Positive) -> Term s r) -> Term s r)
 -> TermCont s (Term s (PValue 'Unsorted 'Positive)))
-> (Term s (PAsData (PValue 'Unsorted 'NoGuarantees))
    -> (Term s (PValue 'Unsorted 'Positive) -> Term s r) -> Term s r)
-> Term s (PAsData (PValue 'Unsorted 'NoGuarantees))
-> TermCont s (Term s (PValue 'Unsorted 'Positive))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PValue 'Unsorted 'Positive)
-> (Term s (PValue 'Unsorted 'Positive) -> Term s r) -> Term s r
forall (s :: S) (a :: PType) (b :: PType).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s (PValue 'Unsorted 'Positive)
 -> (Term s (PValue 'Unsorted 'Positive) -> Term s r) -> Term s r)
-> (Term s (PAsData (PValue 'Unsorted 'NoGuarantees))
    -> Term s (PValue 'Unsorted 'Positive))
-> Term s (PAsData (PValue 'Unsorted 'NoGuarantees))
-> (Term s (PValue 'Unsorted 'Positive) -> Term s r)
-> Term s r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term
  s (PValue 'Unsorted 'NoGuarantees :--> PValue 'Unsorted 'Positive)
-> Term s (PValue 'Unsorted 'NoGuarantees)
-> Term s (PValue 'Unsorted 'Positive)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
papp Term
  s (PValue 'Unsorted 'NoGuarantees :--> PValue 'Unsorted 'Positive)
forall (kg :: KeyGuarantees) (ag :: AmountGuarantees) (s :: S).
Term s (PValue kg ag :--> PValue kg 'Positive)
passertPositive (Term s (PValue 'Unsorted 'NoGuarantees)
 -> Term s (PValue 'Unsorted 'Positive))
-> (Term s (PAsData (PValue 'Unsorted 'NoGuarantees))
    -> Term s (PValue 'Unsorted 'NoGuarantees))
-> Term s (PAsData (PValue 'Unsorted 'NoGuarantees))
-> Term s (PValue 'Unsorted 'Positive)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PAsData (PValue 'Unsorted 'NoGuarantees))
-> Term s (PValue 'Unsorted 'NoGuarantees)
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData (PValue 'Unsorted 'NoGuarantees))
 -> TermCont s (Term s (PValue 'Unsorted 'Positive)))
-> Term s (PAsData (PValue 'Unsorted 'NoGuarantees))
-> TermCont s (Term s (PValue 'Unsorted 'Positive))
forall a b. (a -> b) -> a -> b
$ Term s (PAsData (PValue 'Unsorted 'NoGuarantees))
opq'
    (Term s (PAsData (PValue 'Unsorted 'Positive)),
 Term s (PValue 'Unsorted 'Positive))
-> TermCont
     s
     (Term s (PAsData (PValue 'Unsorted 'Positive)),
      Term s (PValue 'Unsorted 'Positive))
forall a. a -> TermCont s a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Term s PData -> Term s (PAsData (PValue 'Unsorted 'Positive))
forall (b :: PType) (a :: PType) (s :: S). Term s a -> Term s b
punsafeCoerce Term s PData
opq, Term s (PValue 'Unsorted 'Positive)
unwrapped)

-- | @since 2.0.0
instance PTryFrom PData (PAsData (PValue 'AssocMap.Sorted 'NonZero)) where
  type PTryFromExcess PData (PAsData (PValue 'AssocMap.Sorted 'NonZero)) = Mret (PValue 'AssocMap.Sorted 'NonZero)
  ptryFrom' :: forall (s :: S) (r :: PType).
Term s PData
-> ((Term s (PAsData (PValue 'Sorted 'NonZero)),
     Reduce
       (PTryFromExcess PData (PAsData (PValue 'Sorted 'NonZero)) s))
    -> Term s r)
-> Term s r
ptryFrom' Term s PData
opq = TermCont
  s
  (Term s (PAsData (PValue 'Sorted 'NonZero)),
   Reduce
     (PTryFromExcess PData (PAsData (PValue 'Sorted 'NonZero)) s))
-> ((Term s (PAsData (PValue 'Sorted 'NonZero)),
     Reduce
       (PTryFromExcess PData (PAsData (PValue 'Sorted 'NonZero)) s))
    -> Term s r)
-> Term s r
forall (r :: PType) (s :: S) a.
TermCont s a -> (a -> Term s r) -> Term s r
runTermCont (TermCont
   s
   (Term s (PAsData (PValue 'Sorted 'NonZero)),
    Reduce
      (PTryFromExcess PData (PAsData (PValue 'Sorted 'NonZero)) s))
 -> ((Term s (PAsData (PValue 'Sorted 'NonZero)),
      Reduce
        (PTryFromExcess PData (PAsData (PValue 'Sorted 'NonZero)) s))
     -> Term s r)
 -> Term s r)
-> TermCont
     s
     (Term s (PAsData (PValue 'Sorted 'NonZero)),
      Reduce
        (PTryFromExcess PData (PAsData (PValue 'Sorted 'NonZero)) s))
-> ((Term s (PAsData (PValue 'Sorted 'NonZero)),
     Reduce
       (PTryFromExcess PData (PAsData (PValue 'Sorted 'NonZero)) s))
    -> Term s r)
-> Term s r
forall a b. (a -> b) -> a -> b
$ do
    (Term s (PAsData (PValue 'Sorted 'NoGuarantees))
opq', Term
  s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
_) <- (((Term s (PAsData (PValue 'Sorted 'NoGuarantees)),
   Term
     s
     (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
  -> Term s r)
 -> Term s r)
-> TermCont
     s
     (Term s (PAsData (PValue 'Sorted 'NoGuarantees)),
      Term
        s
        (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont ((((Term s (PAsData (PValue 'Sorted 'NoGuarantees)),
    Term
      s
      (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
   -> Term s r)
  -> Term s r)
 -> TermCont
      s
      (Term s (PAsData (PValue 'Sorted 'NoGuarantees)),
       Term
         s
         (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))))
-> (((Term s (PAsData (PValue 'Sorted 'NoGuarantees)),
      Term
        s
        (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
     -> Term s r)
    -> Term s r)
-> TermCont
     s
     (Term s (PAsData (PValue 'Sorted 'NoGuarantees)),
      Term
        s
        (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
forall a b. (a -> b) -> a -> b
$ forall (b :: PType) (a :: PType) (s :: S) (r :: PType).
PTryFrom a b =>
Term s a
-> ((Term s b, Reduce (PTryFromExcess a b s)) -> Term s r)
-> Term s r
ptryFrom @(PAsData (PValue 'AssocMap.Sorted 'NoGuarantees)) Term s PData
opq
    Term s (PValue 'Sorted 'NonZero)
unwrapped <- ((Term s (PValue 'Sorted 'NonZero) -> Term s r) -> Term s r)
-> TermCont s (Term s (PValue 'Sorted 'NonZero))
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s (PValue 'Sorted 'NonZero) -> Term s r) -> Term s r)
 -> TermCont s (Term s (PValue 'Sorted 'NonZero)))
-> (Term s (PAsData (PValue 'Sorted 'NoGuarantees))
    -> (Term s (PValue 'Sorted 'NonZero) -> Term s r) -> Term s r)
-> Term s (PAsData (PValue 'Sorted 'NoGuarantees))
-> TermCont s (Term s (PValue 'Sorted 'NonZero))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PValue 'Sorted 'NonZero)
-> (Term s (PValue 'Sorted 'NonZero) -> Term s r) -> Term s r
forall (s :: S) (a :: PType) (b :: PType).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s (PValue 'Sorted 'NonZero)
 -> (Term s (PValue 'Sorted 'NonZero) -> Term s r) -> Term s r)
-> (Term s (PAsData (PValue 'Sorted 'NoGuarantees))
    -> Term s (PValue 'Sorted 'NonZero))
-> Term s (PAsData (PValue 'Sorted 'NoGuarantees))
-> (Term s (PValue 'Sorted 'NonZero) -> Term s r)
-> Term s r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PValue 'Sorted 'NoGuarantees :--> PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NoGuarantees)
-> Term s (PValue 'Sorted 'NonZero)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
papp Term s (PValue 'Sorted 'NoGuarantees :--> PValue 'Sorted 'NonZero)
forall (kg :: KeyGuarantees) (ag :: AmountGuarantees) (s :: S).
Term s (PValue kg ag :--> PValue kg 'NonZero)
passertNonZero (Term s (PValue 'Sorted 'NoGuarantees)
 -> Term s (PValue 'Sorted 'NonZero))
-> (Term s (PAsData (PValue 'Sorted 'NoGuarantees))
    -> Term s (PValue 'Sorted 'NoGuarantees))
-> Term s (PAsData (PValue 'Sorted 'NoGuarantees))
-> Term s (PValue 'Sorted 'NonZero)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PAsData (PValue 'Sorted 'NoGuarantees))
-> Term s (PValue 'Sorted 'NoGuarantees)
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData (PValue 'Sorted 'NoGuarantees))
 -> TermCont s (Term s (PValue 'Sorted 'NonZero)))
-> Term s (PAsData (PValue 'Sorted 'NoGuarantees))
-> TermCont s (Term s (PValue 'Sorted 'NonZero))
forall a b. (a -> b) -> a -> b
$ Term s (PAsData (PValue 'Sorted 'NoGuarantees))
opq'
    (Term s (PAsData (PValue 'Sorted 'NonZero)),
 Term s (PValue 'Sorted 'NonZero))
-> TermCont
     s
     (Term s (PAsData (PValue 'Sorted 'NonZero)),
      Term s (PValue 'Sorted 'NonZero))
forall a. a -> TermCont s a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Term s PData -> Term s (PAsData (PValue 'Sorted 'NonZero))
forall (b :: PType) (a :: PType) (s :: S). Term s a -> Term s b
punsafeCoerce Term s PData
opq, Term s (PValue 'Sorted 'NonZero)
unwrapped)

-- | @since 2.1.1
instance PTryFrom PData (PAsData (PValue 'AssocMap.Unsorted 'NonZero)) where
  type PTryFromExcess PData (PAsData (PValue 'AssocMap.Unsorted 'NonZero)) = Mret (PValue 'AssocMap.Unsorted 'NonZero)
  ptryFrom' :: forall (s :: S) (r :: PType).
Term s PData
-> ((Term s (PAsData (PValue 'Unsorted 'NonZero)),
     Reduce
       (PTryFromExcess PData (PAsData (PValue 'Unsorted 'NonZero)) s))
    -> Term s r)
-> Term s r
ptryFrom' Term s PData
opq = TermCont
  s
  (Term s (PAsData (PValue 'Unsorted 'NonZero)),
   Reduce
     (PTryFromExcess PData (PAsData (PValue 'Unsorted 'NonZero)) s))
-> ((Term s (PAsData (PValue 'Unsorted 'NonZero)),
     Reduce
       (PTryFromExcess PData (PAsData (PValue 'Unsorted 'NonZero)) s))
    -> Term s r)
-> Term s r
forall (r :: PType) (s :: S) a.
TermCont s a -> (a -> Term s r) -> Term s r
runTermCont (TermCont
   s
   (Term s (PAsData (PValue 'Unsorted 'NonZero)),
    Reduce
      (PTryFromExcess PData (PAsData (PValue 'Unsorted 'NonZero)) s))
 -> ((Term s (PAsData (PValue 'Unsorted 'NonZero)),
      Reduce
        (PTryFromExcess PData (PAsData (PValue 'Unsorted 'NonZero)) s))
     -> Term s r)
 -> Term s r)
-> TermCont
     s
     (Term s (PAsData (PValue 'Unsorted 'NonZero)),
      Reduce
        (PTryFromExcess PData (PAsData (PValue 'Unsorted 'NonZero)) s))
-> ((Term s (PAsData (PValue 'Unsorted 'NonZero)),
     Reduce
       (PTryFromExcess PData (PAsData (PValue 'Unsorted 'NonZero)) s))
    -> Term s r)
-> Term s r
forall a b. (a -> b) -> a -> b
$ do
    (Term s (PAsData (PValue 'Unsorted 'NoGuarantees))
opq', Term
  s
  (PMap
     'Unsorted PCurrencySymbol (PMap 'Unsorted PTokenName PInteger))
_) <- (((Term s (PAsData (PValue 'Unsorted 'NoGuarantees)),
   Term
     s
     (PMap
        'Unsorted PCurrencySymbol (PMap 'Unsorted PTokenName PInteger)))
  -> Term s r)
 -> Term s r)
-> TermCont
     s
     (Term s (PAsData (PValue 'Unsorted 'NoGuarantees)),
      Term
        s
        (PMap
           'Unsorted PCurrencySymbol (PMap 'Unsorted PTokenName PInteger)))
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont ((((Term s (PAsData (PValue 'Unsorted 'NoGuarantees)),
    Term
      s
      (PMap
         'Unsorted PCurrencySymbol (PMap 'Unsorted PTokenName PInteger)))
   -> Term s r)
  -> Term s r)
 -> TermCont
      s
      (Term s (PAsData (PValue 'Unsorted 'NoGuarantees)),
       Term
         s
         (PMap
            'Unsorted PCurrencySymbol (PMap 'Unsorted PTokenName PInteger))))
-> (((Term s (PAsData (PValue 'Unsorted 'NoGuarantees)),
      Term
        s
        (PMap
           'Unsorted PCurrencySymbol (PMap 'Unsorted PTokenName PInteger)))
     -> Term s r)
    -> Term s r)
-> TermCont
     s
     (Term s (PAsData (PValue 'Unsorted 'NoGuarantees)),
      Term
        s
        (PMap
           'Unsorted PCurrencySymbol (PMap 'Unsorted PTokenName PInteger)))
forall a b. (a -> b) -> a -> b
$ forall (b :: PType) (a :: PType) (s :: S) (r :: PType).
PTryFrom a b =>
Term s a
-> ((Term s b, Reduce (PTryFromExcess a b s)) -> Term s r)
-> Term s r
ptryFrom @(PAsData (PValue 'AssocMap.Unsorted 'NoGuarantees)) Term s PData
opq
    Term s (PValue 'Unsorted 'NonZero)
unwrapped <- ((Term s (PValue 'Unsorted 'NonZero) -> Term s r) -> Term s r)
-> TermCont s (Term s (PValue 'Unsorted 'NonZero))
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s (PValue 'Unsorted 'NonZero) -> Term s r) -> Term s r)
 -> TermCont s (Term s (PValue 'Unsorted 'NonZero)))
-> (Term s (PAsData (PValue 'Unsorted 'NoGuarantees))
    -> (Term s (PValue 'Unsorted 'NonZero) -> Term s r) -> Term s r)
-> Term s (PAsData (PValue 'Unsorted 'NoGuarantees))
-> TermCont s (Term s (PValue 'Unsorted 'NonZero))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PValue 'Unsorted 'NonZero)
-> (Term s (PValue 'Unsorted 'NonZero) -> Term s r) -> Term s r
forall (s :: S) (a :: PType) (b :: PType).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s (PValue 'Unsorted 'NonZero)
 -> (Term s (PValue 'Unsorted 'NonZero) -> Term s r) -> Term s r)
-> (Term s (PAsData (PValue 'Unsorted 'NoGuarantees))
    -> Term s (PValue 'Unsorted 'NonZero))
-> Term s (PAsData (PValue 'Unsorted 'NoGuarantees))
-> (Term s (PValue 'Unsorted 'NonZero) -> Term s r)
-> Term s r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term
  s (PValue 'Unsorted 'NoGuarantees :--> PValue 'Unsorted 'NonZero)
-> Term s (PValue 'Unsorted 'NoGuarantees)
-> Term s (PValue 'Unsorted 'NonZero)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
papp Term
  s (PValue 'Unsorted 'NoGuarantees :--> PValue 'Unsorted 'NonZero)
forall (kg :: KeyGuarantees) (ag :: AmountGuarantees) (s :: S).
Term s (PValue kg ag :--> PValue kg 'NonZero)
passertNonZero (Term s (PValue 'Unsorted 'NoGuarantees)
 -> Term s (PValue 'Unsorted 'NonZero))
-> (Term s (PAsData (PValue 'Unsorted 'NoGuarantees))
    -> Term s (PValue 'Unsorted 'NoGuarantees))
-> Term s (PAsData (PValue 'Unsorted 'NoGuarantees))
-> Term s (PValue 'Unsorted 'NonZero)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PAsData (PValue 'Unsorted 'NoGuarantees))
-> Term s (PValue 'Unsorted 'NoGuarantees)
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData (PValue 'Unsorted 'NoGuarantees))
 -> TermCont s (Term s (PValue 'Unsorted 'NonZero)))
-> Term s (PAsData (PValue 'Unsorted 'NoGuarantees))
-> TermCont s (Term s (PValue 'Unsorted 'NonZero))
forall a b. (a -> b) -> a -> b
$ Term s (PAsData (PValue 'Unsorted 'NoGuarantees))
opq'
    (Term s (PAsData (PValue 'Unsorted 'NonZero)),
 Term s (PValue 'Unsorted 'NonZero))
-> TermCont
     s
     (Term s (PAsData (PValue 'Unsorted 'NonZero)),
      Term s (PValue 'Unsorted 'NonZero))
forall a. a -> TermCont s a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Term s PData -> Term s (PAsData (PValue 'Unsorted 'NonZero))
forall (b :: PType) (a :: PType) (s :: S). Term s a -> Term s b
punsafeCoerce Term s PData
opq, Term s (PValue 'Unsorted 'NonZero)
unwrapped)

-- | @since WIP
newtype PAssetClass (s :: S) = PAssetClass (Term s (PDataNewtype (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName))))
  deriving stock
    ( -- | @since WIP
      (forall x. PAssetClass s -> Rep (PAssetClass s) x)
-> (forall x. Rep (PAssetClass s) x -> PAssetClass s)
-> Generic (PAssetClass s)
forall x. Rep (PAssetClass s) x -> PAssetClass s
forall x. PAssetClass s -> Rep (PAssetClass s) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (s :: S) x. Rep (PAssetClass s) x -> PAssetClass s
forall (s :: S) x. PAssetClass s -> Rep (PAssetClass s) x
$cfrom :: forall (s :: S) x. PAssetClass s -> Rep (PAssetClass s) x
from :: forall x. PAssetClass s -> Rep (PAssetClass s) x
$cto :: forall (s :: S) x. Rep (PAssetClass s) x -> PAssetClass s
to :: forall x. Rep (PAssetClass s) x -> PAssetClass s
Generic
    )
  deriving anyclass
    ( -- | @since WIP
      (forall (s :: S). PAssetClass s -> Term s (PInner PAssetClass))
-> (forall (s :: S) (b :: PType).
    Term s (PInner PAssetClass)
    -> (PAssetClass s -> Term s b) -> Term s b)
-> PlutusType PAssetClass
forall (s :: S). PAssetClass s -> Term s (PInner PAssetClass)
forall (s :: S) (b :: PType).
Term s (PInner PAssetClass)
-> (PAssetClass s -> Term s b) -> Term s b
forall (a :: PType).
(forall (s :: S). a s -> Term s (PInner a))
-> (forall (s :: S) (b :: PType).
    Term s (PInner a) -> (a s -> Term s b) -> Term s b)
-> PlutusType a
$cpcon' :: forall (s :: S). PAssetClass s -> Term s (PInner PAssetClass)
pcon' :: forall (s :: S). PAssetClass s -> Term s (PInner PAssetClass)
$cpmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PAssetClass)
-> (PAssetClass s -> Term s b) -> Term s b
pmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PAssetClass)
-> (PAssetClass s -> Term s b) -> Term s b
PlutusType
    , -- | @since WIP
      (forall (s :: S).
 Term s (PAsData PAssetClass) -> Term s PAssetClass)
-> (forall (s :: S). Term s PAssetClass -> Term s PData)
-> PIsData PAssetClass
forall (s :: S). Term s (PAsData PAssetClass) -> Term s PAssetClass
forall (s :: S). Term s PAssetClass -> Term s PData
forall (a :: PType).
(forall (s :: S). Term s (PAsData a) -> Term s a)
-> (forall (s :: S). Term s a -> Term s PData) -> PIsData a
$cpfromDataImpl :: forall (s :: S). Term s (PAsData PAssetClass) -> Term s PAssetClass
pfromDataImpl :: forall (s :: S). Term s (PAsData PAssetClass) -> Term s PAssetClass
$cpdataImpl :: forall (s :: S). Term s PAssetClass -> Term s PData
pdataImpl :: forall (s :: S). Term s PAssetClass -> Term s PData
PIsData
    , -- | @since WIP
      (forall (s :: S).
 Term s PAssetClass -> Term s PAssetClass -> Term s PBool)
-> PEq PAssetClass
forall (s :: S).
Term s PAssetClass -> Term s PAssetClass -> Term s PBool
forall (t :: PType).
(forall (s :: S). Term s t -> Term s t -> Term s PBool) -> PEq t
$c#== :: forall (s :: S).
Term s PAssetClass -> Term s PAssetClass -> Term s PBool
#== :: forall (s :: S).
Term s PAssetClass -> Term s PAssetClass -> Term s PBool
PEq
    , -- | @since WIP
      (forall (s :: S). Bool -> Term s PAssetClass -> Term s PString)
-> PShow PAssetClass
forall (s :: S). Bool -> Term s PAssetClass -> Term s PString
forall (t :: PType).
(forall (s :: S). Bool -> Term s t -> Term s PString) -> PShow t
$cpshow' :: forall (s :: S). Bool -> Term s PAssetClass -> Term s PString
pshow' :: forall (s :: S). Bool -> Term s PAssetClass -> Term s PString
PShow
    , -- | @since WIP
      PTryFrom PData
    )

-- | @since WIP
instance POrd PAssetClass where
  {-# INLINEABLE (#<=) #-}
  Term s PAssetClass
ac1 #<= :: forall (s :: S).
Term s PAssetClass -> Term s PAssetClass -> Term s PBool
#<= Term s PAssetClass
ac2 = Term s PAssetClass
-> (PAssetClass s -> Term s PBool) -> Term s PBool
forall (a :: PType) (s :: S) (b :: PType).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s PAssetClass
ac1 ((PAssetClass s -> Term s PBool) -> Term s PBool)
-> (PAssetClass s -> Term s PBool) -> Term s PBool
forall a b. (a -> b) -> a -> b
$ \(PAssetClass Term
  s
  (PDataNewtype
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
ac1') ->
    Term s PAssetClass
-> (PAssetClass s -> Term s PBool) -> Term s PBool
forall (a :: PType) (s :: S) (b :: PType).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s PAssetClass
ac2 ((PAssetClass s -> Term s PBool) -> Term s PBool)
-> (PAssetClass s -> Term s PBool) -> Term s PBool
forall a b. (a -> b) -> a -> b
$ \(PAssetClass Term
  s
  (PDataNewtype
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
ac2') ->
      Term
  s
  (PDataNewtype
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
-> (PDataNewtype
      (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)) s
    -> Term s PBool)
-> Term s PBool
forall (a :: PType) (s :: S) (b :: PType).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term
  s
  (PDataNewtype
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
ac1' ((PDataNewtype
    (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)) s
  -> Term s PBool)
 -> Term s PBool)
-> (PDataNewtype
      (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)) s
    -> Term s PBool)
-> Term s PBool
forall a b. (a -> b) -> a -> b
$ \(PDataNewtype Term
  s
  (PAsData
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
pair1) ->
        Term
  s
  (PDataNewtype
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
-> (PDataNewtype
      (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)) s
    -> Term s PBool)
-> Term s PBool
forall (a :: PType) (s :: S) (b :: PType).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term
  s
  (PDataNewtype
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
ac2' ((PDataNewtype
    (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)) s
  -> Term s PBool)
 -> Term s PBool)
-> (PDataNewtype
      (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)) s
    -> Term s PBool)
-> Term s PBool
forall a b. (a -> b) -> a -> b
$ \(PDataNewtype Term
  s
  (PAsData
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
pair2) ->
          Term s PCurrencySymbol
-> (Term s PCurrencySymbol -> Term s PBool) -> Term s PBool
forall (s :: S) (a :: PType) (b :: PType).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s (PAsData PCurrencySymbol) -> Term s PCurrencySymbol
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData PCurrencySymbol) -> Term s PCurrencySymbol)
-> Term s (PAsData PCurrencySymbol) -> Term s PCurrencySymbol
forall a b. (a -> b) -> a -> b
$ Term
  s
  (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)
   :--> PAsData PCurrencySymbol)
forall (s :: S) (a :: PType) (b :: PType).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term
  s
  (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)
   :--> PAsData PCurrencySymbol)
-> Term
     s (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName))
-> Term s (PAsData PCurrencySymbol)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term
  s
  (PAsData
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
-> Term
     s (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName))
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData Term
  s
  (PAsData
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
pair1) ((Term s PCurrencySymbol -> Term s PBool) -> Term s PBool)
-> (Term s PCurrencySymbol -> Term s PBool) -> Term s PBool
forall a b. (a -> b) -> a -> b
$ \Term s PCurrencySymbol
fst1 ->
            Term s PCurrencySymbol
-> (Term s PCurrencySymbol -> Term s PBool) -> Term s PBool
forall (s :: S) (a :: PType) (b :: PType).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s (PAsData PCurrencySymbol) -> Term s PCurrencySymbol
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData PCurrencySymbol) -> Term s PCurrencySymbol)
-> Term s (PAsData PCurrencySymbol) -> Term s PCurrencySymbol
forall a b. (a -> b) -> a -> b
$ Term
  s
  (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)
   :--> PAsData PCurrencySymbol)
forall (s :: S) (a :: PType) (b :: PType).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term
  s
  (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)
   :--> PAsData PCurrencySymbol)
-> Term
     s (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName))
-> Term s (PAsData PCurrencySymbol)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term
  s
  (PAsData
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
-> Term
     s (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName))
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData Term
  s
  (PAsData
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
pair2) ((Term s PCurrencySymbol -> Term s PBool) -> Term s PBool)
-> (Term s PCurrencySymbol -> Term s PBool) -> Term s PBool
forall a b. (a -> b) -> a -> b
$ \Term s PCurrencySymbol
fst2 ->
              (Term s PCurrencySymbol
fst1 Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool
forall (s :: S).
Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool
forall (t :: PType) (s :: S).
POrd t =>
Term s t -> Term s t -> Term s PBool
#< Term s PCurrencySymbol
fst2)
                #|| ( (fst1 #== fst2)
                        #&& let snd1 = pfromData $ psndBuiltin # pfromData pair1
                                snd2 = pfromData $ psndBuiltin # pfromData pair2
                             in snd1 #<= snd2
                    )
  {-# INLINEABLE (#<) #-}
  Term s PAssetClass
ac1 #< :: forall (s :: S).
Term s PAssetClass -> Term s PAssetClass -> Term s PBool
#< Term s PAssetClass
ac2 = Term s PAssetClass
-> (PAssetClass s -> Term s PBool) -> Term s PBool
forall (a :: PType) (s :: S) (b :: PType).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s PAssetClass
ac1 ((PAssetClass s -> Term s PBool) -> Term s PBool)
-> (PAssetClass s -> Term s PBool) -> Term s PBool
forall a b. (a -> b) -> a -> b
$ \(PAssetClass Term
  s
  (PDataNewtype
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
ac1') ->
    Term s PAssetClass
-> (PAssetClass s -> Term s PBool) -> Term s PBool
forall (a :: PType) (s :: S) (b :: PType).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s PAssetClass
ac2 ((PAssetClass s -> Term s PBool) -> Term s PBool)
-> (PAssetClass s -> Term s PBool) -> Term s PBool
forall a b. (a -> b) -> a -> b
$ \(PAssetClass Term
  s
  (PDataNewtype
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
ac2') ->
      Term
  s
  (PDataNewtype
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
-> (PDataNewtype
      (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)) s
    -> Term s PBool)
-> Term s PBool
forall (a :: PType) (s :: S) (b :: PType).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term
  s
  (PDataNewtype
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
ac1' ((PDataNewtype
    (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)) s
  -> Term s PBool)
 -> Term s PBool)
-> (PDataNewtype
      (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)) s
    -> Term s PBool)
-> Term s PBool
forall a b. (a -> b) -> a -> b
$ \(PDataNewtype Term
  s
  (PAsData
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
pair1) ->
        Term
  s
  (PDataNewtype
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
-> (PDataNewtype
      (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)) s
    -> Term s PBool)
-> Term s PBool
forall (a :: PType) (s :: S) (b :: PType).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term
  s
  (PDataNewtype
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
ac2' ((PDataNewtype
    (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)) s
  -> Term s PBool)
 -> Term s PBool)
-> (PDataNewtype
      (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)) s
    -> Term s PBool)
-> Term s PBool
forall a b. (a -> b) -> a -> b
$ \(PDataNewtype Term
  s
  (PAsData
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
pair2) ->
          Term s PCurrencySymbol
-> (Term s PCurrencySymbol -> Term s PBool) -> Term s PBool
forall (s :: S) (a :: PType) (b :: PType).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s (PAsData PCurrencySymbol) -> Term s PCurrencySymbol
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData PCurrencySymbol) -> Term s PCurrencySymbol)
-> Term s (PAsData PCurrencySymbol) -> Term s PCurrencySymbol
forall a b. (a -> b) -> a -> b
$ Term
  s
  (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)
   :--> PAsData PCurrencySymbol)
forall (s :: S) (a :: PType) (b :: PType).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term
  s
  (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)
   :--> PAsData PCurrencySymbol)
-> Term
     s (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName))
-> Term s (PAsData PCurrencySymbol)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term
  s
  (PAsData
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
-> Term
     s (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName))
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData Term
  s
  (PAsData
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
pair1) ((Term s PCurrencySymbol -> Term s PBool) -> Term s PBool)
-> (Term s PCurrencySymbol -> Term s PBool) -> Term s PBool
forall a b. (a -> b) -> a -> b
$ \Term s PCurrencySymbol
fst1 ->
            Term s PCurrencySymbol
-> (Term s PCurrencySymbol -> Term s PBool) -> Term s PBool
forall (s :: S) (a :: PType) (b :: PType).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s (PAsData PCurrencySymbol) -> Term s PCurrencySymbol
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData PCurrencySymbol) -> Term s PCurrencySymbol)
-> Term s (PAsData PCurrencySymbol) -> Term s PCurrencySymbol
forall a b. (a -> b) -> a -> b
$ Term
  s
  (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)
   :--> PAsData PCurrencySymbol)
forall (s :: S) (a :: PType) (b :: PType).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term
  s
  (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)
   :--> PAsData PCurrencySymbol)
-> Term
     s (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName))
-> Term s (PAsData PCurrencySymbol)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term
  s
  (PAsData
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
-> Term
     s (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName))
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData Term
  s
  (PAsData
     (PBuiltinPair (PAsData PCurrencySymbol) (PAsData PTokenName)))
pair2) ((Term s PCurrencySymbol -> Term s PBool) -> Term s PBool)
-> (Term s PCurrencySymbol -> Term s PBool) -> Term s PBool
forall a b. (a -> b) -> a -> b
$ \Term s PCurrencySymbol
fst2 ->
              (Term s PCurrencySymbol
fst1 Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool
forall (s :: S).
Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool
forall (t :: PType) (s :: S).
POrd t =>
Term s t -> Term s t -> Term s PBool
#< Term s PCurrencySymbol
fst2)
                #|| ( (fst1 #== fst2)
                        #&& let snd1 = pfromData $ psndBuiltin # pfromData pair1
                                snd2 = pfromData $ psndBuiltin # pfromData pair2
                             in snd1 #< snd2
                    )

-- | @since WIP
instance DerivePlutusType PAssetClass where
  type DPTStrat _ = PlutusTypeNewtype

-- | @since WIP
deriving via
  DeriveDataPLiftable PAssetClass PlutusValue.AssetClass
  instance
    PLiftable PAssetClass

-- | @since WIP
instance PTryFrom PData (PAsData PAssetClass)

{- | \'Forget\' that a 'Value' has an only-positive guarantee.

@since 2.0.0
-}
pforgetPositive ::
  forall (a :: AmountGuarantees) (k :: AssocMap.KeyGuarantees) (s :: S).
  Term s (PValue k 'Positive) ->
  Term s (PValue k a)
pforgetPositive :: forall (a :: AmountGuarantees) (k :: KeyGuarantees) (s :: S).
Term s (PValue k 'Positive) -> Term s (PValue k a)
pforgetPositive = Term s (PValue k 'Positive) -> Term s (PValue k a)
forall (b :: PType) (a :: PType) (s :: S). Term s a -> Term s b
punsafeCoerce

{- | Given a description of a relation on amounts, check whether that relation
holds over sorted 'PValue's.

= Important note

This is intended for use with boolean comparison functions, which must define
at least a partial order (total orders and equivalences are acceptable as
well). Use of this with anything else is not guaranteed to give anything
resembling a sensible answer. Use with extreme care.

@since 2.0.0
-}
pcheckBinRel ::
  forall (any0 :: AmountGuarantees) (any1 :: AmountGuarantees) (s :: S).
  Term
    s
    ( (PInteger :--> PInteger :--> PBool)
        :--> PValue 'AssocMap.Sorted any0
        :--> PValue 'AssocMap.Sorted any1
        :--> PBool
    )
pcheckBinRel :: forall (any0 :: AmountGuarantees) (any1 :: AmountGuarantees)
       (s :: S).
Term
  s
  ((PInteger :--> (PInteger :--> PBool))
   :--> (PValue 'Sorted any0 :--> (PValue 'Sorted any1 :--> PBool)))
pcheckBinRel = ClosedTerm
  ((PInteger :--> (PInteger :--> PBool))
   :--> (PValue 'Sorted any0 :--> (PValue 'Sorted any1 :--> PBool)))
-> Term
     s
     ((PInteger :--> (PInteger :--> PBool))
      :--> (PValue 'Sorted any0 :--> (PValue 'Sorted any1 :--> PBool)))
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   ((PInteger :--> (PInteger :--> PBool))
    :--> (PValue 'Sorted any0 :--> (PValue 'Sorted any1 :--> PBool)))
 -> Term
      s
      ((PInteger :--> (PInteger :--> PBool))
       :--> (PValue 'Sorted any0 :--> (PValue 'Sorted any1 :--> PBool))))
-> ClosedTerm
     ((PInteger :--> (PInteger :--> PBool))
      :--> (PValue 'Sorted any0 :--> (PValue 'Sorted any1 :--> PBool)))
-> Term
     s
     ((PInteger :--> (PInteger :--> PBool))
      :--> (PValue 'Sorted any0 :--> (PValue 'Sorted any1 :--> PBool)))
forall a b. (a -> b) -> a -> b
$
  (Term s (PInteger :--> (PInteger :--> PBool))
 -> Term
      s (PValue 'Sorted any0 :--> (PValue 'Sorted any1 :--> PBool)))
-> Term
     s
     ((PInteger :--> (PInteger :--> PBool))
      :--> (PValue 'Sorted any0 :--> (PValue 'Sorted any1 :--> PBool)))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c
 -> Term
      s (PValue 'Sorted any0 :--> (PValue 'Sorted any1 :--> PBool)))
-> Term
     s
     (c
      :--> (PValue 'Sorted any0 :--> (PValue 'Sorted any1 :--> PBool)))
plam ((Term s (PInteger :--> (PInteger :--> PBool))
  -> Term
       s (PValue 'Sorted any0 :--> (PValue 'Sorted any1 :--> PBool)))
 -> Term
      s
      ((PInteger :--> (PInteger :--> PBool))
       :--> (PValue 'Sorted any0 :--> (PValue 'Sorted any1 :--> PBool))))
-> (Term s (PInteger :--> (PInteger :--> PBool))
    -> Term
         s (PValue 'Sorted any0 :--> (PValue 'Sorted any1 :--> PBool)))
-> Term
     s
     ((PInteger :--> (PInteger :--> PBool))
      :--> (PValue 'Sorted any0 :--> (PValue 'Sorted any1 :--> PBool)))
forall a b. (a -> b) -> a -> b
$ \Term s (PInteger :--> (PInteger :--> PBool))
f ->
    forall (b :: PType) (a :: PType) (s :: S). Term s a -> Term s b
punsafeCoerce @(PValue AssocMap.Sorted any0 :--> PValue AssocMap.Sorted any1 :--> PBool) (Term
   s
   (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
    :--> (PMap
            'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
          :--> PBool))
 -> Term
      s (PValue 'Sorted any0 :--> (PValue 'Sorted any1 :--> PBool)))
-> Term
     s
     (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
      :--> (PMap
              'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
            :--> PBool))
-> Term
     s (PValue 'Sorted any0 :--> (PValue 'Sorted any1 :--> PBool))
forall a b. (a -> b) -> a -> b
$
      forall (k :: PType) (v :: PType) (s :: S).
(POrd k, PIsData k, PIsData v) =>
Term
  s
  ((v :--> (v :--> PBool))
   :--> (v
         :--> (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool))))
AssocMap.pcheckBinRel @PCurrencySymbol Term
  s
  ((PMap 'Sorted PTokenName PInteger
    :--> (PMap 'Sorted PTokenName PInteger :--> PBool))
   :--> (PMap 'Sorted PTokenName PInteger
         :--> (PMap
                 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
               :--> (PMap
                       'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
                     :--> PBool))))
-> Term
     s
     (PMap 'Sorted PTokenName PInteger
      :--> (PMap 'Sorted PTokenName PInteger :--> PBool))
-> Term
     s
     (PMap 'Sorted PTokenName PInteger
      :--> (PMap
              'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
            :--> (PMap
                    'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
                  :--> PBool)))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# (forall (k :: PType) (v :: PType) (s :: S).
(POrd k, PIsData k, PIsData v) =>
Term
  s
  ((v :--> (v :--> PBool))
   :--> (v
         :--> (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool))))
AssocMap.pcheckBinRel @PTokenName Term
  s
  ((PInteger :--> (PInteger :--> PBool))
   :--> (PInteger
         :--> (PMap 'Sorted PTokenName PInteger
               :--> (PMap 'Sorted PTokenName PInteger :--> PBool))))
-> Term s (PInteger :--> (PInteger :--> PBool))
-> Term
     s
     (PInteger
      :--> (PMap 'Sorted PTokenName PInteger
            :--> (PMap 'Sorted PTokenName PInteger :--> PBool)))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PInteger :--> (PInteger :--> PBool))
f Term
  s
  (PInteger
   :--> (PMap 'Sorted PTokenName PInteger
         :--> (PMap 'Sorted PTokenName PInteger :--> PBool)))
-> Term s PInteger
-> Term
     s
     (PMap 'Sorted PTokenName PInteger
      :--> (PMap 'Sorted PTokenName PInteger :--> PBool))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PInteger
0) Term
  s
  (PMap 'Sorted PTokenName PInteger
   :--> (PMap
           'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
         :--> (PMap
                 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
               :--> PBool)))
-> Term s (PMap 'Sorted PTokenName PInteger)
-> Term
     s
     (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
      :--> (PMap
              'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
            :--> PBool))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Sorted PTokenName PInteger)
forall (s :: S) (k :: PType) (v :: PType).
Term s (PMap 'Sorted k v)
AssocMap.pempty

{- | Combine two 'PValue's applying the given function to any pair of
 quantities with the same asset class. Note that the result is _not_
 'normalize'd and may contain zero quantities.

 @since 2.0.0
-}
punionResolvingCollisionsWith ::
  forall (any0 :: AmountGuarantees) (any1 :: AmountGuarantees) (s :: S).
  AssocMap.Commutativity ->
  Term
    s
    ( (PInteger :--> PInteger :--> PInteger)
        :--> PValue 'AssocMap.Sorted any0
        :--> PValue 'AssocMap.Sorted any1
        :--> PValue 'AssocMap.Sorted 'NoGuarantees
    )
punionResolvingCollisionsWith :: forall (any0 :: AmountGuarantees) (any1 :: AmountGuarantees)
       (s :: S).
Commutativity
-> Term
     s
     ((PInteger :--> (PInteger :--> PInteger))
      :--> (PValue 'Sorted any0
            :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
punionResolvingCollisionsWith Commutativity
commutativity = ClosedTerm
  ((PInteger :--> (PInteger :--> PInteger))
   :--> (PValue 'Sorted any0
         :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
-> Term
     s
     ((PInteger :--> (PInteger :--> PInteger))
      :--> (PValue 'Sorted any0
            :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   ((PInteger :--> (PInteger :--> PInteger))
    :--> (PValue 'Sorted any0
          :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
 -> Term
      s
      ((PInteger :--> (PInteger :--> PInteger))
       :--> (PValue 'Sorted any0
             :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees))))
-> ClosedTerm
     ((PInteger :--> (PInteger :--> PInteger))
      :--> (PValue 'Sorted any0
            :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
-> Term
     s
     ((PInteger :--> (PInteger :--> PInteger))
      :--> (PValue 'Sorted any0
            :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
forall a b. (a -> b) -> a -> b
$
  (Term s (PInteger :--> (PInteger :--> PInteger))
 -> Term s (PValue 'Sorted any0)
 -> Term s (PValue 'Sorted any1)
 -> Term s (PValue 'Sorted 'NoGuarantees))
-> Term
     s
     ((PInteger :--> (PInteger :--> PInteger))
      :--> (PValue 'Sorted any0
            :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c
 -> Term s (PValue 'Sorted any0)
 -> Term s (PValue 'Sorted any1)
 -> Term s (PValue 'Sorted 'NoGuarantees))
-> Term
     s
     (c
      :--> (PValue 'Sorted any0
            :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
plam ((Term s (PInteger :--> (PInteger :--> PInteger))
  -> Term s (PValue 'Sorted any0)
  -> Term s (PValue 'Sorted any1)
  -> Term s (PValue 'Sorted 'NoGuarantees))
 -> Term
      s
      ((PInteger :--> (PInteger :--> PInteger))
       :--> (PValue 'Sorted any0
             :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees))))
-> (Term s (PInteger :--> (PInteger :--> PInteger))
    -> Term s (PValue 'Sorted any0)
    -> Term s (PValue 'Sorted any1)
    -> Term s (PValue 'Sorted 'NoGuarantees))
-> Term
     s
     ((PInteger :--> (PInteger :--> PInteger))
      :--> (PValue 'Sorted any0
            :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
forall a b. (a -> b) -> a -> b
$ \Term s (PInteger :--> (PInteger :--> PInteger))
combine Term s (PValue 'Sorted any0)
x Term s (PValue 'Sorted any1)
y ->
    PValue 'Sorted 'NoGuarantees s
-> Term s (PValue 'Sorted 'NoGuarantees)
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PValue 'Sorted 'NoGuarantees s
 -> Term s (PValue 'Sorted 'NoGuarantees))
-> (Term
      s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
    -> PValue 'Sorted 'NoGuarantees s)
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term s (PValue 'Sorted 'NoGuarantees)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term
  s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> PValue 'Sorted 'NoGuarantees s
forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S).
Term s (PMap keys PCurrencySymbol (PMap keys PTokenName PInteger))
-> PValue keys amounts s
PValue (Term
   s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
 -> Term s (PValue 'Sorted 'NoGuarantees))
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term s (PValue 'Sorted 'NoGuarantees)
forall a b. (a -> b) -> a -> b
$
      Commutativity
-> Term
     s
     ((PMap 'Sorted PTokenName PInteger
       :--> (PMap 'Sorted PTokenName PInteger
             :--> PMap 'Sorted PTokenName PInteger))
      :--> (PMap
              'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
            :--> (PMap
                    'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
                  :--> PMap
                         'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))))
forall (k :: PType) (v :: PType) (s :: S).
(POrd k, PIsData k, PIsData v) =>
Commutativity
-> Term
     s
     ((v :--> (v :--> v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
AssocMap.punionResolvingCollisionsWith Commutativity
commutativity
        # plam (\x' y' -> AssocMap.punionResolvingCollisionsWith commutativity # combine # x' # y')
        # pto x
        # pto y

{- | Normalize the argument to contain no zero quantity nor empty token map.

@since 2.0.0
-}
pnormalize ::
  forall (any :: AmountGuarantees) (s :: S).
  Term s (PValue 'AssocMap.Sorted any :--> PValue 'AssocMap.Sorted 'NonZero)
pnormalize :: forall (any :: AmountGuarantees) (s :: S).
Term s (PValue 'Sorted any :--> PValue 'Sorted 'NonZero)
pnormalize = ClosedTerm (PValue 'Sorted any :--> PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted any :--> PValue 'Sorted 'NonZero)
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm (PValue 'Sorted any :--> PValue 'Sorted 'NonZero)
 -> Term s (PValue 'Sorted any :--> PValue 'Sorted 'NonZero))
-> ClosedTerm (PValue 'Sorted any :--> PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted any :--> PValue 'Sorted 'NonZero)
forall a b. (a -> b) -> a -> b
$
  (Term s (PValue 'Sorted any) -> Term s (PValue 'Sorted 'NonZero))
-> Term s (PValue 'Sorted any :--> PValue 'Sorted 'NonZero)
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s (PValue 'Sorted 'NonZero))
-> Term s (c :--> PValue 'Sorted 'NonZero)
plam ((Term s (PValue 'Sorted any) -> Term s (PValue 'Sorted 'NonZero))
 -> Term s (PValue 'Sorted any :--> PValue 'Sorted 'NonZero))
-> (Term s (PValue 'Sorted any)
    -> Term s (PValue 'Sorted 'NonZero))
-> Term s (PValue 'Sorted any :--> PValue 'Sorted 'NonZero)
forall a b. (a -> b) -> a -> b
$ \Term s (PValue 'Sorted any)
value ->
    PValue 'Sorted 'NonZero s -> Term s (PValue 'Sorted 'NonZero)
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PValue 'Sorted 'NonZero s -> Term s (PValue 'Sorted 'NonZero))
-> (Term
      s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
    -> PValue 'Sorted 'NonZero s)
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term s (PValue 'Sorted 'NonZero)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term
  s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> PValue 'Sorted 'NonZero s
forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S).
Term s (PMap keys PCurrencySymbol (PMap keys PTokenName PInteger))
-> PValue keys amounts s
PValue (Term
   s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
 -> Term s (PValue 'Sorted 'NonZero))
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term s (PValue 'Sorted 'NonZero)
forall a b. (a -> b) -> a -> b
$
      Term
  s
  ((PMap 'Sorted PTokenName PInteger
    :--> PMaybe (PMap 'Sorted PTokenName PInteger))
   :--> (PMap
           'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
         :--> PMap
                'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
forall (g :: KeyGuarantees) (k :: PType) (a :: PType) (b :: PType)
       (s :: S).
(PIsData a, PIsData b) =>
Term s ((a :--> PMaybe b) :--> (PMap g k a :--> PMap g k b))
AssocMap.pmapMaybe Term
  s
  ((PMap 'Sorted PTokenName PInteger
    :--> PMaybe (PMap 'Sorted PTokenName PInteger))
   :--> (PMap
           'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
         :--> PMap
                'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
-> Term
     s
     (PMap 'Sorted PTokenName PInteger
      :--> PMaybe (PMap 'Sorted PTokenName PInteger))
-> Term
     s
     (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
      :--> PMap
             'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s (PMap 'Sorted PTokenName PInteger)
 -> Term s (PMaybe (PMap 'Sorted PTokenName PInteger)))
-> Term
     s
     (PMap 'Sorted PTokenName PInteger
      :--> PMaybe (PMap 'Sorted PTokenName PInteger))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s (PMaybe (PMap 'Sorted PTokenName PInteger)))
-> Term s (c :--> PMaybe (PMap 'Sorted PTokenName PInteger))
plam Term s (PMap 'Sorted PTokenName PInteger)
-> Term s (PMaybe (PMap 'Sorted PTokenName PInteger))
forall (s' :: S) (k :: PType) (any1 :: KeyGuarantees).
Term s' (PMap any1 k PInteger)
-> Term s' (PMaybe (PMap any1 k PInteger))
normalizeTokenMap Term
  s
  (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
   :--> PMap
          'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PValue 'Sorted any) -> Term s (PInner (PValue 'Sorted any))
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto Term s (PValue 'Sorted any)
value
  where
    normalizeTokenMap ::
      forall (s' :: S) (k :: S -> Type) (any1 :: AssocMap.KeyGuarantees).
      Term s' (AssocMap.PMap any1 k PInteger) ->
      Term s' (PMaybe (AssocMap.PMap any1 k PInteger))
    normalizeTokenMap :: forall (s' :: S) (k :: PType) (any1 :: KeyGuarantees).
Term s' (PMap any1 k PInteger)
-> Term s' (PMaybe (PMap any1 k PInteger))
normalizeTokenMap Term s' (PMap any1 k PInteger)
tokenMap =
      Term s' (PMap any1 k PInteger)
-> (Term s' (PMap any1 k PInteger)
    -> Term s' (PMaybe (PMap any1 k PInteger)))
-> Term s' (PMaybe (PMap any1 k PInteger))
forall (s :: S) (a :: PType) (b :: PType).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term
  s'
  ((PAsData PInteger :--> PMaybe (PAsData PInteger))
   :--> (PMap any1 k PInteger :--> PMap any1 k PInteger))
forall (g :: KeyGuarantees) (k :: PType) (a :: PType) (b :: PType)
       (s :: S).
Term
  s
  ((PAsData a :--> PMaybe (PAsData b))
   :--> (PMap g k a :--> PMap g k b))
AssocMap.pmapMaybeData Term
  s'
  ((PAsData PInteger :--> PMaybe (PAsData PInteger))
   :--> (PMap any1 k PInteger :--> PMap any1 k PInteger))
-> Term s' (PAsData PInteger :--> PMaybe (PAsData PInteger))
-> Term s' (PMap any1 k PInteger :--> PMap any1 k PInteger)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s' (PAsData PInteger) -> Term s' (PMaybe (PAsData PInteger)))
-> Term s' (PAsData PInteger :--> PMaybe (PAsData PInteger))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s' c -> Term s' (PMaybe (PAsData PInteger)))
-> Term s' (c :--> PMaybe (PAsData PInteger))
plam Term s' (PAsData PInteger) -> Term s' (PMaybe (PAsData PInteger))
forall (s' :: S).
Term s' (PAsData PInteger) -> Term s' (PMaybe (PAsData PInteger))
nonZero Term s' (PMap any1 k PInteger :--> PMap any1 k PInteger)
-> Term s' (PMap any1 k PInteger) -> Term s' (PMap any1 k PInteger)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s' (PMap any1 k PInteger)
tokenMap) ((Term s' (PMap any1 k PInteger)
  -> Term s' (PMaybe (PMap any1 k PInteger)))
 -> Term s' (PMaybe (PMap any1 k PInteger)))
-> (Term s' (PMap any1 k PInteger)
    -> Term s' (PMaybe (PMap any1 k PInteger)))
-> Term s' (PMaybe (PMap any1 k PInteger))
forall a b. (a -> b) -> a -> b
$ \Term s' (PMap any1 k PInteger)
normalMap ->
        Term s' PBool
-> Term s' (PMaybe (PMap any1 k PInteger))
-> Term s' (PMaybe (PMap any1 k PInteger))
-> Term s' (PMaybe (PMap any1 k PInteger))
forall (a :: PType) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
          (Term s' (PMap any1 k PInteger :--> PBool)
forall (any :: KeyGuarantees) (k :: PType) (v :: PType) (s :: S).
Term s (PMap any k v :--> PBool)
AssocMap.pnull Term s' (PMap any1 k PInteger :--> PBool)
-> Term s' (PMap any1 k PInteger) -> Term s' PBool
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s' (PMap any1 k PInteger)
normalMap)
          (PMaybe (PMap any1 k PInteger) s'
-> Term s' (PMaybe (PMap any1 k PInteger))
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon PMaybe (PMap any1 k PInteger) s'
forall (a :: PType) (s :: S). PMaybe a s
PNothing)
          (PMaybe (PMap any1 k PInteger) s'
-> Term s' (PMaybe (PMap any1 k PInteger))
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PMaybe (PMap any1 k PInteger) s'
 -> Term s' (PMaybe (PMap any1 k PInteger)))
-> PMaybe (PMap any1 k PInteger) s'
-> Term s' (PMaybe (PMap any1 k PInteger))
forall a b. (a -> b) -> a -> b
$ Term s' (PMap any1 k PInteger) -> PMaybe (PMap any1 k PInteger) s'
forall (a :: PType) (s :: S). Term s a -> PMaybe a s
PJust Term s' (PMap any1 k PInteger)
normalMap)
    nonZero ::
      forall (s' :: S).
      Term s' (PAsData PInteger) ->
      Term s' (PMaybe (PAsData PInteger))
    nonZero :: forall (s' :: S).
Term s' (PAsData PInteger) -> Term s' (PMaybe (PAsData PInteger))
nonZero Term s' (PAsData PInteger)
intData =
      Term s' PBool
-> Term s' (PMaybe (PAsData PInteger))
-> Term s' (PMaybe (PAsData PInteger))
-> Term s' (PMaybe (PAsData PInteger))
forall (a :: PType) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif (Term s' (PAsData PInteger)
intData Term s' (PAsData PInteger)
-> Term s' (PAsData PInteger) -> Term s' PBool
forall (s :: S).
Term s (PAsData PInteger)
-> Term s (PAsData PInteger) -> Term s PBool
forall (t :: PType) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s' (PAsData PInteger)
forall (s :: S). Term s (PAsData PInteger)
zeroData) (PMaybe (PAsData PInteger) s' -> Term s' (PMaybe (PAsData PInteger))
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon PMaybe (PAsData PInteger) s'
forall (a :: PType) (s :: S). PMaybe a s
PNothing) (PMaybe (PAsData PInteger) s' -> Term s' (PMaybe (PAsData PInteger))
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PMaybe (PAsData PInteger) s'
 -> Term s' (PMaybe (PAsData PInteger)))
-> PMaybe (PAsData PInteger) s'
-> Term s' (PMaybe (PAsData PInteger))
forall a b. (a -> b) -> a -> b
$ Term s' (PAsData PInteger) -> PMaybe (PAsData PInteger) s'
forall (a :: PType) (s :: S). Term s a -> PMaybe a s
PJust Term s' (PAsData PInteger)
intData)

{- | Given a 'PValue', either construct another 'PValue' with the same contents
and a proof that all amounts in it are positive, or error.

@since 2.0.0
-}
passertPositive ::
  forall (kg :: AssocMap.KeyGuarantees) (ag :: AmountGuarantees) (s :: S).
  Term s (PValue kg ag :--> PValue kg 'Positive)
passertPositive :: forall (kg :: KeyGuarantees) (ag :: AmountGuarantees) (s :: S).
Term s (PValue kg ag :--> PValue kg 'Positive)
passertPositive = ClosedTerm (PValue kg ag :--> PValue kg 'Positive)
-> Term s (PValue kg ag :--> PValue kg 'Positive)
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm (PValue kg ag :--> PValue kg 'Positive)
 -> Term s (PValue kg ag :--> PValue kg 'Positive))
-> ClosedTerm (PValue kg ag :--> PValue kg 'Positive)
-> Term s (PValue kg ag :--> PValue kg 'Positive)
forall a b. (a -> b) -> a -> b
$
  (Term s (PValue kg ag) -> Term s (PValue kg 'Positive))
-> Term s (PValue kg ag :--> PValue kg 'Positive)
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s (PValue kg 'Positive))
-> Term s (c :--> PValue kg 'Positive)
plam ((Term s (PValue kg ag) -> Term s (PValue kg 'Positive))
 -> Term s (PValue kg ag :--> PValue kg 'Positive))
-> (Term s (PValue kg ag) -> Term s (PValue kg 'Positive))
-> Term s (PValue kg ag :--> PValue kg 'Positive)
forall a b. (a -> b) -> a -> b
$ \Term s (PValue kg ag)
value ->
    Term s PBool
-> Term s (PValue kg 'Positive)
-> Term s (PValue kg 'Positive)
-> Term s (PValue kg 'Positive)
forall (a :: PType) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
      ( Term
  s
  ((PMap kg PTokenName PInteger :--> PBool)
   :--> (PMap kg PCurrencySymbol (PMap kg PTokenName PInteger)
         :--> PBool))
forall (any :: KeyGuarantees) (k :: PType) (v :: PType) (s :: S).
PIsData v =>
Term s ((v :--> PBool) :--> (PMap any k v :--> PBool))
AssocMap.pall
          # plam (\submap -> AssocMap.pall # plam (0 #<) # submap)
          # pto value
      )
      (Term s (PInner (PValue kg 'Positive))
-> Term s (PValue kg 'Positive)
forall (s :: S) (a :: PType). Term s (PInner a) -> Term s a
punsafeDowncast (Term s (PInner (PValue kg 'Positive))
 -> Term s (PValue kg 'Positive))
-> Term s (PInner (PValue kg 'Positive))
-> Term s (PValue kg 'Positive)
forall a b. (a -> b) -> a -> b
$ Term s (PValue kg ag) -> Term s (PInner (PValue kg ag))
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto Term s (PValue kg ag)
value)
      (Term s PString -> Term s (PValue kg 'Positive)
forall (a :: PType) (s :: S). Term s PString -> Term s a
ptraceInfoError Term s PString
"Negative amount in Value")

{- | Construct a constant singleton 'PValue' containing only the given
positive quantity of the given currency.

@since 2.1.1
-}
pconstantPositiveSingleton ::
  forall (s :: S).
  (forall (s' :: S). Term s' PCurrencySymbol) ->
  (forall (s' :: S). Term s' PTokenName) ->
  (forall (s' :: S). Term s' PInteger) ->
  Term s (PValue 'AssocMap.Sorted 'Positive)
pconstantPositiveSingleton :: forall (s :: S).
(forall (s' :: S). Term s' PCurrencySymbol)
-> (forall (s' :: S). Term s' PTokenName)
-> (forall (s' :: S). Term s' PInteger)
-> Term s (PValue 'Sorted 'Positive)
pconstantPositiveSingleton forall (s' :: S). Term s' PCurrencySymbol
symbol forall (s' :: S). Term s' PTokenName
token forall (s' :: S). Term s' PInteger
amount
  | (forall (s' :: S). Term s' PInteger) -> AsHaskell PInteger
forall (a :: PType).
PLiftable a =>
(forall (s :: S). Term s a) -> AsHaskell a
plift Term s PInteger
forall (s' :: S). Term s' PInteger
amount AsHaskell PInteger -> AsHaskell PInteger -> Bool
forall a. Eq a => a -> a -> Bool
== AsHaskell PInteger
0 = Term s (PValue 'Sorted 'Positive)
forall a. Monoid a => a
mempty
  | (forall (s' :: S). Term s' PInteger) -> AsHaskell PInteger
forall (a :: PType).
PLiftable a =>
(forall (s :: S). Term s a) -> AsHaskell a
plift Term s PInteger
forall (s' :: S). Term s' PInteger
amount AsHaskell PInteger -> AsHaskell PInteger -> Bool
forall a. Ord a => a -> a -> Bool
< AsHaskell PInteger
0 = [Char] -> Term s (PValue 'Sorted 'Positive)
forall a. HasCallStack => [Char] -> a
error [Char]
"Negative amount"
  | Bool
otherwise = Term s (PInner (PValue 'Sorted 'Positive))
-> Term s (PValue 'Sorted 'Positive)
forall (s :: S) (a :: PType). Term s (PInner a) -> Term s a
punsafeDowncast (Term
  s
  (PCurrencySymbol
   :--> (PMap 'Sorted PTokenName PInteger
         :--> PMap
                'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
forall (k :: PType) (v :: PType) (s :: S).
(PIsData k, PIsData v) =>
Term s (k :--> (v :--> PMap 'Sorted k v))
AssocMap.psingleton Term
  s
  (PCurrencySymbol
   :--> (PMap 'Sorted PTokenName PInteger
         :--> PMap
                'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
-> Term s PCurrencySymbol
-> Term
     s
     (PMap 'Sorted PTokenName PInteger
      :--> PMap
             'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PCurrencySymbol
forall (s' :: S). Term s' PCurrencySymbol
symbol Term
  s
  (PMap 'Sorted PTokenName PInteger
   :--> PMap
          'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term s (PMap 'Sorted PTokenName PInteger)
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
#$ Term
  s
  (PTokenName :--> (PInteger :--> PMap 'Sorted PTokenName PInteger))
forall (k :: PType) (v :: PType) (s :: S).
(PIsData k, PIsData v) =>
Term s (k :--> (v :--> PMap 'Sorted k v))
AssocMap.psingleton Term
  s
  (PTokenName :--> (PInteger :--> PMap 'Sorted PTokenName PInteger))
-> Term s PTokenName
-> Term s (PInteger :--> PMap 'Sorted PTokenName PInteger)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PTokenName
forall (s' :: S). Term s' PTokenName
token Term s (PInteger :--> PMap 'Sorted PTokenName PInteger)
-> Term s PInteger -> Term s (PMap 'Sorted PTokenName PInteger)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PInteger
forall (s' :: S). Term s' PInteger
amount)

{- | The 'PCurrencySymbol' of the Ada currency.

@since 2.1.1
-}
padaSymbol :: forall (s :: S). Term s PCurrencySymbol
padaSymbol :: forall (s' :: S). Term s' PCurrencySymbol
padaSymbol = AsHaskell PCurrencySymbol -> Term s PCurrencySymbol
forall (a :: PType) (s :: S).
PLiftable a =>
AsHaskell a -> Term s a
pconstant AsHaskell PCurrencySymbol
CurrencySymbol
Plutus.adaSymbol

{- | Data-encoded 'PCurrencySymbol' of the Ada currency.

@since 2.1.1
-}
padaSymbolData :: forall (s :: S). Term s (PAsData PCurrencySymbol)
padaSymbolData :: forall (s :: S). Term s (PAsData PCurrencySymbol)
padaSymbolData = Term s PCurrencySymbol -> Term s (PAsData PCurrencySymbol)
forall (a :: PType) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata Term s PCurrencySymbol
forall (s' :: S). Term s' PCurrencySymbol
padaSymbol

{- | The 'PTokenName' of the Ada currency.

@since 2.1.1
-}
padaToken :: Term s PTokenName
padaToken :: forall (s' :: S). Term s' PTokenName
padaToken = AsHaskell PTokenName -> Term s PTokenName
forall (a :: PType) (s :: S).
PLiftable a =>
AsHaskell a -> Term s a
pconstant AsHaskell PTokenName
TokenName
Plutus.adaToken

{- | Forget the knowledge of all value's guarantees.

@since 2.1.1
-}
pforgetSorted ::
  forall (a :: AmountGuarantees) (k :: AssocMap.KeyGuarantees) (s :: S).
  Term s (PValue 'AssocMap.Sorted a) ->
  Term s (PValue k a)
pforgetSorted :: forall (a :: AmountGuarantees) (k :: KeyGuarantees) (s :: S).
Term s (PValue 'Sorted a) -> Term s (PValue k a)
pforgetSorted = Term s (PValue 'Sorted a) -> Term s (PValue k a)
forall (b :: PType) (a :: PType) (s :: S). Term s a -> Term s b
punsafeCoerce

{- | Construct a singleton 'PValue' containing only the given quantity of the
given currency.

@since 2.1.1
-}
psingleton ::
  forall (s :: S).
  Term
    s
    (PCurrencySymbol :--> PTokenName :--> PInteger :--> PValue 'AssocMap.Sorted 'NonZero)
psingleton :: forall (s :: S).
Term
  s
  (PCurrencySymbol
   :--> (PTokenName :--> (PInteger :--> PValue 'Sorted 'NonZero)))
psingleton = (forall (s :: S).
 Term
   s
   (PCurrencySymbol
    :--> (PTokenName :--> (PInteger :--> PValue 'Sorted 'NonZero))))
-> Term
     s
     (PCurrencySymbol
      :--> (PTokenName :--> (PInteger :--> PValue 'Sorted 'NonZero)))
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic ((forall (s :: S).
  Term
    s
    (PCurrencySymbol
     :--> (PTokenName :--> (PInteger :--> PValue 'Sorted 'NonZero))))
 -> Term
      s
      (PCurrencySymbol
       :--> (PTokenName :--> (PInteger :--> PValue 'Sorted 'NonZero))))
-> (forall (s :: S).
    Term
      s
      (PCurrencySymbol
       :--> (PTokenName :--> (PInteger :--> PValue 'Sorted 'NonZero))))
-> Term
     s
     (PCurrencySymbol
      :--> (PTokenName :--> (PInteger :--> PValue 'Sorted 'NonZero)))
forall a b. (a -> b) -> a -> b
$
  (Term s PCurrencySymbol
 -> Term s PTokenName
 -> Term s PInteger
 -> Term s (PValue 'Sorted 'NonZero))
-> Term
     s
     (PCurrencySymbol
      :--> (PTokenName :--> (PInteger :--> PValue 'Sorted 'NonZero)))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c
 -> Term s PTokenName
 -> Term s PInteger
 -> Term s (PValue 'Sorted 'NonZero))
-> Term
     s
     (c :--> (PTokenName :--> (PInteger :--> PValue 'Sorted 'NonZero)))
plam ((Term s PCurrencySymbol
  -> Term s PTokenName
  -> Term s PInteger
  -> Term s (PValue 'Sorted 'NonZero))
 -> Term
      s
      (PCurrencySymbol
       :--> (PTokenName :--> (PInteger :--> PValue 'Sorted 'NonZero))))
-> (Term s PCurrencySymbol
    -> Term s PTokenName
    -> Term s PInteger
    -> Term s (PValue 'Sorted 'NonZero))
-> Term
     s
     (PCurrencySymbol
      :--> (PTokenName :--> (PInteger :--> PValue 'Sorted 'NonZero)))
forall a b. (a -> b) -> a -> b
$ \Term s PCurrencySymbol
symbol Term s PTokenName
token Term s PInteger
amount ->
    Term s PBool
-> Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NonZero)
forall (a :: PType) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
      (Term s PInteger
amount Term s PInteger -> Term s PInteger -> Term s PBool
forall (s :: S). Term s PInteger -> Term s PInteger -> Term s PBool
forall (t :: PType) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s PInteger
0)
      Term s (PValue 'Sorted 'NonZero)
forall a. Monoid a => a
mempty
      (Term s (PInner (PValue 'Sorted 'NonZero))
-> Term s (PValue 'Sorted 'NonZero)
forall (s :: S) (a :: PType). Term s (PInner a) -> Term s a
punsafeDowncast (Term s (PInner (PValue 'Sorted 'NonZero))
 -> Term s (PValue 'Sorted 'NonZero))
-> Term s (PInner (PValue 'Sorted 'NonZero))
-> Term s (PValue 'Sorted 'NonZero)
forall a b. (a -> b) -> a -> b
$ Term
  s
  (PCurrencySymbol
   :--> (PMap 'Sorted PTokenName PInteger
         :--> PMap
                'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
forall (k :: PType) (v :: PType) (s :: S).
(PIsData k, PIsData v) =>
Term s (k :--> (v :--> PMap 'Sorted k v))
AssocMap.psingleton Term
  s
  (PCurrencySymbol
   :--> (PMap 'Sorted PTokenName PInteger
         :--> PMap
                'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
-> Term s PCurrencySymbol
-> Term
     s
     (PMap 'Sorted PTokenName PInteger
      :--> PMap
             'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PCurrencySymbol
symbol Term
  s
  (PMap 'Sorted PTokenName PInteger
   :--> PMap
          'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term s (PMap 'Sorted PTokenName PInteger)
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
#$ Term
  s
  (PTokenName :--> (PInteger :--> PMap 'Sorted PTokenName PInteger))
forall (k :: PType) (v :: PType) (s :: S).
(PIsData k, PIsData v) =>
Term s (k :--> (v :--> PMap 'Sorted k v))
AssocMap.psingleton Term
  s
  (PTokenName :--> (PInteger :--> PMap 'Sorted PTokenName PInteger))
-> Term s PTokenName
-> Term s (PInteger :--> PMap 'Sorted PTokenName PInteger)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PTokenName
token Term s (PInteger :--> PMap 'Sorted PTokenName PInteger)
-> Term s PInteger -> Term s (PMap 'Sorted PTokenName PInteger)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PInteger
amount)

{- | Construct a singleton 'PValue' containing only the given quantity of the
 given currency, taking data-encoded parameters.

 @since 2.1.1
-}
psingletonData ::
  forall (s :: S).
  Term
    s
    ( PAsData PCurrencySymbol
        :--> PAsData PTokenName
        :--> PAsData PInteger
        :--> PValue 'AssocMap.Sorted 'NonZero
    )
psingletonData :: forall (s :: S).
Term
  s
  (PAsData PCurrencySymbol
   :--> (PAsData PTokenName
         :--> (PAsData PInteger :--> PValue 'Sorted 'NonZero)))
psingletonData = (forall (s :: S).
 Term
   s
   (PAsData PCurrencySymbol
    :--> (PAsData PTokenName
          :--> (PAsData PInteger :--> PValue 'Sorted 'NonZero))))
-> Term
     s
     (PAsData PCurrencySymbol
      :--> (PAsData PTokenName
            :--> (PAsData PInteger :--> PValue 'Sorted 'NonZero)))
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic ((forall (s :: S).
  Term
    s
    (PAsData PCurrencySymbol
     :--> (PAsData PTokenName
           :--> (PAsData PInteger :--> PValue 'Sorted 'NonZero))))
 -> Term
      s
      (PAsData PCurrencySymbol
       :--> (PAsData PTokenName
             :--> (PAsData PInteger :--> PValue 'Sorted 'NonZero))))
-> (forall (s :: S).
    Term
      s
      (PAsData PCurrencySymbol
       :--> (PAsData PTokenName
             :--> (PAsData PInteger :--> PValue 'Sorted 'NonZero))))
-> Term
     s
     (PAsData PCurrencySymbol
      :--> (PAsData PTokenName
            :--> (PAsData PInteger :--> PValue 'Sorted 'NonZero)))
forall a b. (a -> b) -> a -> b
$
  (Term s (PAsData PCurrencySymbol)
 -> Term s (PAsData PTokenName)
 -> Term s (PAsData PInteger)
 -> Term s (PValue 'Sorted 'NonZero))
-> Term
     s
     (PAsData PCurrencySymbol
      :--> (PAsData PTokenName
            :--> (PAsData PInteger :--> PValue 'Sorted 'NonZero)))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c
 -> Term s (PAsData PTokenName)
 -> Term s (PAsData PInteger)
 -> Term s (PValue 'Sorted 'NonZero))
-> Term
     s
     (c
      :--> (PAsData PTokenName
            :--> (PAsData PInteger :--> PValue 'Sorted 'NonZero)))
plam ((Term s (PAsData PCurrencySymbol)
  -> Term s (PAsData PTokenName)
  -> Term s (PAsData PInteger)
  -> Term s (PValue 'Sorted 'NonZero))
 -> Term
      s
      (PAsData PCurrencySymbol
       :--> (PAsData PTokenName
             :--> (PAsData PInteger :--> PValue 'Sorted 'NonZero))))
-> (Term s (PAsData PCurrencySymbol)
    -> Term s (PAsData PTokenName)
    -> Term s (PAsData PInteger)
    -> Term s (PValue 'Sorted 'NonZero))
-> Term
     s
     (PAsData PCurrencySymbol
      :--> (PAsData PTokenName
            :--> (PAsData PInteger :--> PValue 'Sorted 'NonZero)))
forall a b. (a -> b) -> a -> b
$ \Term s (PAsData PCurrencySymbol)
symbol Term s (PAsData PTokenName)
token Term s (PAsData PInteger)
amount ->
    Term s PBool
-> Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NonZero)
forall (a :: PType) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
      (Term s (PAsData PInteger)
amount Term s (PAsData PInteger)
-> Term s (PAsData PInteger) -> Term s PBool
forall (s :: S).
Term s (PAsData PInteger)
-> Term s (PAsData PInteger) -> Term s PBool
forall (t :: PType) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s (PAsData PInteger)
forall (s :: S). Term s (PAsData PInteger)
zeroData)
      Term s (PValue 'Sorted 'NonZero)
forall a. Monoid a => a
mempty
      ( Term s (PInner (PValue 'Sorted 'NonZero))
-> Term s (PValue 'Sorted 'NonZero)
forall (s :: S) (a :: PType). Term s (PInner a) -> Term s a
punsafeDowncast
          ( Term
  s
  (PAsData PCurrencySymbol
   :--> (PAsData (PMap 'Sorted PTokenName PInteger)
         :--> PMap
                'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
forall (k :: PType) (v :: PType) (s :: S).
Term s (PAsData k :--> (PAsData v :--> PMap 'Sorted k v))
AssocMap.psingletonData
              # symbol
              #$ pdata
              $ AssocMap.psingletonData # token # amount
          )
      )

{- | Get the quantity of the given currency in the 'PValue'.

@since 2.1.1
-}
pvalueOf ::
  forall (anyKey :: AssocMap.KeyGuarantees) (anyAmount :: AmountGuarantees) (s :: S).
  Term s (PValue anyKey anyAmount :--> PCurrencySymbol :--> PTokenName :--> PInteger)
pvalueOf :: forall (anyKey :: KeyGuarantees) (anyAmount :: AmountGuarantees)
       (s :: S).
Term
  s
  (PValue anyKey anyAmount
   :--> (PCurrencySymbol :--> (PTokenName :--> PInteger)))
pvalueOf = ClosedTerm
  (PValue anyKey anyAmount
   :--> (PCurrencySymbol :--> (PTokenName :--> PInteger)))
-> Term
     s
     (PValue anyKey anyAmount
      :--> (PCurrencySymbol :--> (PTokenName :--> PInteger)))
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   (PValue anyKey anyAmount
    :--> (PCurrencySymbol :--> (PTokenName :--> PInteger)))
 -> Term
      s
      (PValue anyKey anyAmount
       :--> (PCurrencySymbol :--> (PTokenName :--> PInteger))))
-> ClosedTerm
     (PValue anyKey anyAmount
      :--> (PCurrencySymbol :--> (PTokenName :--> PInteger)))
-> Term
     s
     (PValue anyKey anyAmount
      :--> (PCurrencySymbol :--> (PTokenName :--> PInteger)))
forall a b. (a -> b) -> a -> b
$
  (Term s (PValue anyKey anyAmount)
 -> Term s PCurrencySymbol -> Term s PTokenName -> Term s PInteger)
-> Term
     s
     (PValue anyKey anyAmount
      :--> (PCurrencySymbol :--> (PTokenName :--> PInteger)))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c
 -> Term s PCurrencySymbol -> Term s PTokenName -> Term s PInteger)
-> Term
     s (c :--> (PCurrencySymbol :--> (PTokenName :--> PInteger)))
plam ((Term s (PValue anyKey anyAmount)
  -> Term s PCurrencySymbol -> Term s PTokenName -> Term s PInteger)
 -> Term
      s
      (PValue anyKey anyAmount
       :--> (PCurrencySymbol :--> (PTokenName :--> PInteger))))
-> (Term s (PValue anyKey anyAmount)
    -> Term s PCurrencySymbol -> Term s PTokenName -> Term s PInteger)
-> Term
     s
     (PValue anyKey anyAmount
      :--> (PCurrencySymbol :--> (PTokenName :--> PInteger)))
forall a b. (a -> b) -> a -> b
$ \Term s (PValue anyKey anyAmount)
value Term s PCurrencySymbol
symbol Term s PTokenName
token ->
    Term
  s
  (PCurrencySymbol
   :--> (PInteger
         :--> ((PAsData (PMap anyKey PTokenName PInteger) :--> PInteger)
               :--> (PMap anyKey PCurrencySymbol (PMap anyKey PTokenName PInteger)
                     :--> PInteger))))
forall (k :: PType) (v :: PType) (any :: KeyGuarantees)
       (r :: PType) (s :: S).
PIsData k =>
Term
  s (k :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
AssocMap.pfoldAt
      # symbol
      # 0
      # plam (\m -> AssocMap.pfoldAt # token # 0 # plam pfromData # pfromData m)
      # pto value

{- | Get the amount of Lovelace in the 'PValue'.

@since 2.1.1
-}
plovelaceValueOf ::
  forall (v :: AmountGuarantees) (s :: S).
  Term s (PValue 'AssocMap.Sorted v :--> PInteger)
plovelaceValueOf :: forall (v :: AmountGuarantees) (s :: S).
Term s (PValue 'Sorted v :--> PInteger)
plovelaceValueOf = ClosedTerm (PValue 'Sorted v :--> PInteger)
-> Term s (PValue 'Sorted v :--> PInteger)
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm (PValue 'Sorted v :--> PInteger)
 -> Term s (PValue 'Sorted v :--> PInteger))
-> ClosedTerm (PValue 'Sorted v :--> PInteger)
-> Term s (PValue 'Sorted v :--> PInteger)
forall a b. (a -> b) -> a -> b
$
  (Term s (PValue 'Sorted v) -> Term s PInteger)
-> Term s (PValue 'Sorted v :--> PInteger)
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s PInteger) -> Term s (c :--> PInteger)
plam ((Term s (PValue 'Sorted v) -> Term s PInteger)
 -> Term s (PValue 'Sorted v :--> PInteger))
-> (Term s (PValue 'Sorted v) -> Term s PInteger)
-> Term s (PValue 'Sorted v :--> PInteger)
forall a b. (a -> b) -> a -> b
$ \Term s (PValue 'Sorted v)
value ->
    Term
  s
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol)
        (PAsData (PMap 'Sorted PTokenName PInteger))))
-> (PBuiltinList
      (PBuiltinPair
         (PAsData PCurrencySymbol)
         (PAsData (PMap 'Sorted PTokenName PInteger)))
      s
    -> Term s PInteger)
-> Term s PInteger
forall (a :: PType) (s :: S) (b :: PType).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch (Term
  s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term
     s
     (PInner
        (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto (Term
   s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
 -> Term
      s
      (PInner
         (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))))
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term
     s
     (PInner
        (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
forall a b. (a -> b) -> a -> b
$ Term s (PValue 'Sorted v) -> Term s (PInner (PValue 'Sorted v))
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto Term s (PValue 'Sorted v)
value) ((PBuiltinList
    (PBuiltinPair
       (PAsData PCurrencySymbol)
       (PAsData (PMap 'Sorted PTokenName PInteger)))
    s
  -> Term s PInteger)
 -> Term s PInteger)
-> (PBuiltinList
      (PBuiltinPair
         (PAsData PCurrencySymbol)
         (PAsData (PMap 'Sorted PTokenName PInteger)))
      s
    -> Term s PInteger)
-> Term s PInteger
forall a b. (a -> b) -> a -> b
$ \case
      PBuiltinList
  (PBuiltinPair
     (PAsData PCurrencySymbol)
     (PAsData (PMap 'Sorted PTokenName PInteger)))
  s
PNil -> Term s PInteger
0
      PCons Term
  s
  (PBuiltinPair
     (PAsData PCurrencySymbol)
     (PAsData (PMap 'Sorted PTokenName PInteger)))
x Term
  s
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol)
        (PAsData (PMap 'Sorted PTokenName PInteger))))
_ ->
        Term s (PBool :--> (PInteger :--> (PInteger :--> PInteger)))
forall (a :: PType) (s :: S).
Term s (PBool :--> (a :--> (a :--> a)))
pif'
          # (pfstBuiltin # x #== padaSymbolData)
          # pfromData (psndBuiltin #$ phead #$ pto $ pfromData $ psndBuiltin # x)
          # 0

{- | Combine two 'PValue's, taking the tokens from the left only, if a
currency occurs on both sides.

@since 2.1.1
-}
pleftBiasedCurrencyUnion ::
  forall (any0 :: AmountGuarantees) (any1 :: AmountGuarantees) (s :: S).
  Term
    s
    ( PValue 'AssocMap.Sorted any0
        :--> PValue 'AssocMap.Sorted any1
        :--> PValue 'AssocMap.Sorted 'NoGuarantees
    )
pleftBiasedCurrencyUnion :: forall (any0 :: AmountGuarantees) (any1 :: AmountGuarantees)
       (s :: S).
Term
  s
  (PValue 'Sorted any0
   :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees))
pleftBiasedCurrencyUnion = ClosedTerm
  (PValue 'Sorted any0
   :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees))
-> Term
     s
     (PValue 'Sorted any0
      :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees))
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   (PValue 'Sorted any0
    :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees))
 -> Term
      s
      (PValue 'Sorted any0
       :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
-> ClosedTerm
     (PValue 'Sorted any0
      :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees))
-> Term
     s
     (PValue 'Sorted any0
      :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees))
forall a b. (a -> b) -> a -> b
$
  (Term s (PValue 'Sorted any0)
 -> Term s (PValue 'Sorted any1)
 -> Term s (PValue 'Sorted 'NoGuarantees))
-> Term
     s
     (PValue 'Sorted any0
      :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c
 -> Term s (PValue 'Sorted any1)
 -> Term s (PValue 'Sorted 'NoGuarantees))
-> Term
     s (c :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees))
plam ((Term s (PValue 'Sorted any0)
  -> Term s (PValue 'Sorted any1)
  -> Term s (PValue 'Sorted 'NoGuarantees))
 -> Term
      s
      (PValue 'Sorted any0
       :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
-> (Term s (PValue 'Sorted any0)
    -> Term s (PValue 'Sorted any1)
    -> Term s (PValue 'Sorted 'NoGuarantees))
-> Term
     s
     (PValue 'Sorted any0
      :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees))
forall a b. (a -> b) -> a -> b
$
    \Term s (PValue 'Sorted any0)
x Term s (PValue 'Sorted any1)
y -> PValue 'Sorted 'NoGuarantees s
-> Term s (PValue 'Sorted 'NoGuarantees)
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PValue 'Sorted 'NoGuarantees s
 -> Term s (PValue 'Sorted 'NoGuarantees))
-> (Term
      s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
    -> PValue 'Sorted 'NoGuarantees s)
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term s (PValue 'Sorted 'NoGuarantees)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term
  s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> PValue 'Sorted 'NoGuarantees s
forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S).
Term s (PMap keys PCurrencySymbol (PMap keys PTokenName PInteger))
-> PValue keys amounts s
PValue (Term
   s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
 -> Term s (PValue 'Sorted 'NoGuarantees))
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term s (PValue 'Sorted 'NoGuarantees)
forall a b. (a -> b) -> a -> b
$ Term
  s
  (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
   :--> (PMap
           'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
         :--> PMap
                'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
forall (k :: PType) (v :: PType) (s :: S).
(POrd k, PIsData k, PIsData v) =>
Term
  s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
AssocMap.pleftBiasedUnion Term
  s
  (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
   :--> (PMap
           'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
         :--> PMap
                'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term
     s
     (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
      :--> PMap
             'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PValue 'Sorted any0)
-> Term s (PInner (PValue 'Sorted any0))
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto Term s (PValue 'Sorted any0)
x Term
  s
  (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
   :--> PMap
          'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PValue 'Sorted any1)
-> Term s (PInner (PValue 'Sorted any1))
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto Term s (PValue 'Sorted any1)
y

{- | Combine two 'PValue's, taking the tokens from the left only, if a token name
 of the same currency occurs on both sides.

 Prefer this over 'punionResolvingCollisionsWith NonCommutative # plam const'.
 It is equivalent, but performs better.

 @since 2.1.1
-}
pleftBiasedTokenUnion ::
  forall (any0 :: AmountGuarantees) (any1 :: AmountGuarantees) (s :: S).
  Term
    s
    ( PValue 'AssocMap.Sorted any0
        :--> PValue 'AssocMap.Sorted any1
        :--> PValue 'AssocMap.Sorted 'NoGuarantees
    )
pleftBiasedTokenUnion :: forall (any0 :: AmountGuarantees) (any1 :: AmountGuarantees)
       (s :: S).
Term
  s
  (PValue 'Sorted any0
   :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees))
pleftBiasedTokenUnion = ClosedTerm
  (PValue 'Sorted any0
   :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees))
-> Term
     s
     (PValue 'Sorted any0
      :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees))
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   (PValue 'Sorted any0
    :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees))
 -> Term
      s
      (PValue 'Sorted any0
       :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
-> ClosedTerm
     (PValue 'Sorted any0
      :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees))
-> Term
     s
     (PValue 'Sorted any0
      :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees))
forall a b. (a -> b) -> a -> b
$
  (Term s (PValue 'Sorted any0)
 -> Term s (PValue 'Sorted any1)
 -> Term s (PValue 'Sorted 'NoGuarantees))
-> Term
     s
     (PValue 'Sorted any0
      :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c
 -> Term s (PValue 'Sorted any1)
 -> Term s (PValue 'Sorted 'NoGuarantees))
-> Term
     s (c :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees))
plam ((Term s (PValue 'Sorted any0)
  -> Term s (PValue 'Sorted any1)
  -> Term s (PValue 'Sorted 'NoGuarantees))
 -> Term
      s
      (PValue 'Sorted any0
       :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
-> (Term s (PValue 'Sorted any0)
    -> Term s (PValue 'Sorted any1)
    -> Term s (PValue 'Sorted 'NoGuarantees))
-> Term
     s
     (PValue 'Sorted any0
      :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees))
forall a b. (a -> b) -> a -> b
$ \Term s (PValue 'Sorted any0)
x Term s (PValue 'Sorted any1)
y ->
    PValue 'Sorted 'NoGuarantees s
-> Term s (PValue 'Sorted 'NoGuarantees)
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PValue 'Sorted 'NoGuarantees s
 -> Term s (PValue 'Sorted 'NoGuarantees))
-> (Term
      s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
    -> PValue 'Sorted 'NoGuarantees s)
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term s (PValue 'Sorted 'NoGuarantees)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term
  s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> PValue 'Sorted 'NoGuarantees s
forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S).
Term s (PMap keys PCurrencySymbol (PMap keys PTokenName PInteger))
-> PValue keys amounts s
PValue (Term
   s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
 -> Term s (PValue 'Sorted 'NoGuarantees))
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term s (PValue 'Sorted 'NoGuarantees)
forall a b. (a -> b) -> a -> b
$
      Commutativity
-> Term
     s
     ((PMap 'Sorted PTokenName PInteger
       :--> (PMap 'Sorted PTokenName PInteger
             :--> PMap 'Sorted PTokenName PInteger))
      :--> (PMap
              'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
            :--> (PMap
                    'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
                  :--> PMap
                         'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))))
forall (k :: PType) (v :: PType) (s :: S).
(POrd k, PIsData k, PIsData v) =>
Commutativity
-> Term
     s
     ((v :--> (v :--> v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
AssocMap.punionResolvingCollisionsWith Commutativity
AssocMap.NonCommutative
        # plam (\x' y' -> AssocMap.pleftBiasedUnion # x' # y')
        # pto x
        # pto y

{- | Combine two 'PValue's applying the given function to any pair of
 data-encoded quantities with the same asset class. Note that the result is
 _not_ 'normalize'd and may contain zero quantities.

 @since 2.1.1
-}
punionResolvingCollisionsWithData ::
  forall (any0 :: AmountGuarantees) (any1 :: AmountGuarantees) (s :: S).
  AssocMap.Commutativity ->
  Term
    s
    ( (PAsData PInteger :--> PAsData PInteger :--> PAsData PInteger)
        :--> PValue 'AssocMap.Sorted any0
        :--> PValue 'AssocMap.Sorted any1
        :--> PValue 'AssocMap.Sorted 'NoGuarantees
    )
punionResolvingCollisionsWithData :: forall (any0 :: AmountGuarantees) (any1 :: AmountGuarantees)
       (s :: S).
Commutativity
-> Term
     s
     ((PAsData PInteger :--> (PAsData PInteger :--> PAsData PInteger))
      :--> (PValue 'Sorted any0
            :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
punionResolvingCollisionsWithData Commutativity
commutativity = ClosedTerm
  ((PAsData PInteger :--> (PAsData PInteger :--> PAsData PInteger))
   :--> (PValue 'Sorted any0
         :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
-> Term
     s
     ((PAsData PInteger :--> (PAsData PInteger :--> PAsData PInteger))
      :--> (PValue 'Sorted any0
            :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   ((PAsData PInteger :--> (PAsData PInteger :--> PAsData PInteger))
    :--> (PValue 'Sorted any0
          :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
 -> Term
      s
      ((PAsData PInteger :--> (PAsData PInteger :--> PAsData PInteger))
       :--> (PValue 'Sorted any0
             :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees))))
-> ClosedTerm
     ((PAsData PInteger :--> (PAsData PInteger :--> PAsData PInteger))
      :--> (PValue 'Sorted any0
            :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
-> Term
     s
     ((PAsData PInteger :--> (PAsData PInteger :--> PAsData PInteger))
      :--> (PValue 'Sorted any0
            :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
forall a b. (a -> b) -> a -> b
$
  (Term
   s (PAsData PInteger :--> (PAsData PInteger :--> PAsData PInteger))
 -> Term s (PValue 'Sorted any0)
 -> Term s (PValue 'Sorted any1)
 -> Term s (PValue 'Sorted 'NoGuarantees))
-> Term
     s
     ((PAsData PInteger :--> (PAsData PInteger :--> PAsData PInteger))
      :--> (PValue 'Sorted any0
            :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c
 -> Term s (PValue 'Sorted any0)
 -> Term s (PValue 'Sorted any1)
 -> Term s (PValue 'Sorted 'NoGuarantees))
-> Term
     s
     (c
      :--> (PValue 'Sorted any0
            :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
plam ((Term
    s (PAsData PInteger :--> (PAsData PInteger :--> PAsData PInteger))
  -> Term s (PValue 'Sorted any0)
  -> Term s (PValue 'Sorted any1)
  -> Term s (PValue 'Sorted 'NoGuarantees))
 -> Term
      s
      ((PAsData PInteger :--> (PAsData PInteger :--> PAsData PInteger))
       :--> (PValue 'Sorted any0
             :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees))))
-> (Term
      s (PAsData PInteger :--> (PAsData PInteger :--> PAsData PInteger))
    -> Term s (PValue 'Sorted any0)
    -> Term s (PValue 'Sorted any1)
    -> Term s (PValue 'Sorted 'NoGuarantees))
-> Term
     s
     ((PAsData PInteger :--> (PAsData PInteger :--> PAsData PInteger))
      :--> (PValue 'Sorted any0
            :--> (PValue 'Sorted any1 :--> PValue 'Sorted 'NoGuarantees)))
forall a b. (a -> b) -> a -> b
$ \Term
  s (PAsData PInteger :--> (PAsData PInteger :--> PAsData PInteger))
combine Term s (PValue 'Sorted any0)
x Term s (PValue 'Sorted any1)
y ->
    PValue 'Sorted 'NoGuarantees s
-> Term s (PValue 'Sorted 'NoGuarantees)
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PValue 'Sorted 'NoGuarantees s
 -> Term s (PValue 'Sorted 'NoGuarantees))
-> (Term
      s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
    -> PValue 'Sorted 'NoGuarantees s)
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term s (PValue 'Sorted 'NoGuarantees)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term
  s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> PValue 'Sorted 'NoGuarantees s
forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S).
Term s (PMap keys PCurrencySymbol (PMap keys PTokenName PInteger))
-> PValue keys amounts s
PValue (Term
   s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
 -> Term s (PValue 'Sorted 'NoGuarantees))
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term s (PValue 'Sorted 'NoGuarantees)
forall a b. (a -> b) -> a -> b
$
      Commutativity
-> Term
     s
     ((PMap 'Sorted PTokenName PInteger
       :--> (PMap 'Sorted PTokenName PInteger
             :--> PMap 'Sorted PTokenName PInteger))
      :--> (PMap
              'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
            :--> (PMap
                    'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
                  :--> PMap
                         'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))))
forall (k :: PType) (v :: PType) (s :: S).
(POrd k, PIsData k, PIsData v) =>
Commutativity
-> Term
     s
     ((v :--> (v :--> v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
AssocMap.punionResolvingCollisionsWith Commutativity
commutativity
        # plam (\x' y' -> AssocMap.punionResolvingCollisionsWithData commutativity # combine # x' # y')
        # pto x
        # pto y

{- | Assert the value is properly sorted and normalized.

@since 2.1.1
-}
passertSorted ::
  forall (anyKey :: AssocMap.KeyGuarantees) (anyAmount :: AmountGuarantees) (s :: S).
  Term s (PValue anyKey anyAmount :--> PValue 'AssocMap.Sorted 'NonZero)
passertSorted :: forall (anyKey :: KeyGuarantees) (anyAmount :: AmountGuarantees)
       (s :: S).
Term s (PValue anyKey anyAmount :--> PValue 'Sorted 'NonZero)
passertSorted = ClosedTerm (PValue anyKey anyAmount :--> PValue 'Sorted 'NonZero)
-> Term s (PValue anyKey anyAmount :--> PValue 'Sorted 'NonZero)
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm (PValue anyKey anyAmount :--> PValue 'Sorted 'NonZero)
 -> Term s (PValue anyKey anyAmount :--> PValue 'Sorted 'NonZero))
-> ClosedTerm
     (PValue anyKey anyAmount :--> PValue 'Sorted 'NonZero)
-> Term s (PValue anyKey anyAmount :--> PValue 'Sorted 'NonZero)
forall a b. (a -> b) -> a -> b
$
  (Term s (PValue anyKey anyAmount)
 -> Term s (PValue 'Sorted 'NonZero))
-> Term s (PValue anyKey anyAmount :--> PValue 'Sorted 'NonZero)
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s (PValue 'Sorted 'NonZero))
-> Term s (c :--> PValue 'Sorted 'NonZero)
plam ((Term s (PValue anyKey anyAmount)
  -> Term s (PValue 'Sorted 'NonZero))
 -> Term s (PValue anyKey anyAmount :--> PValue 'Sorted 'NonZero))
-> (Term s (PValue anyKey anyAmount)
    -> Term s (PValue 'Sorted 'NonZero))
-> Term s (PValue anyKey anyAmount :--> PValue 'Sorted 'NonZero)
forall a b. (a -> b) -> a -> b
$ \Term s (PValue anyKey anyAmount)
value ->
    Term s PBool
-> Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NonZero)
-> Term s (PValue 'Sorted 'NonZero)
forall (a :: PType) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
      ( Term
  s
  ((PMap anyKey PTokenName PInteger :--> PBool)
   :--> (PMap anyKey PCurrencySymbol (PMap anyKey PTokenName PInteger)
         :--> PBool))
forall (k :: PType) (v :: PType) (any :: KeyGuarantees) (s :: S).
PIsData v =>
Term s ((v :--> PBool) :--> (PMap any k v :--> PBool))
AssocMap.pany
          # plam
            ( \submap ->
                AssocMap.pnull
                  # (AssocMap.passertSorted # submap)
                  #|| AssocMap.pany
                  # plam (#== 0)
                  # submap
            )
          # pto value
      )
      (Term s PString -> Term s (PValue 'Sorted 'NonZero)
forall (a :: PType) (s :: S). Term s PString -> Term s a
ptraceInfoError Term s PString
"Abnormal Value")
      (Term s (PValue 'Sorted 'NonZero)
 -> Term s (PValue 'Sorted 'NonZero))
-> (Term
      s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
    -> Term s (PValue 'Sorted 'NonZero))
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term s (PValue 'Sorted 'NonZero)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PValue 'Sorted 'NonZero s -> Term s (PValue 'Sorted 'NonZero)
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon
      (PValue 'Sorted 'NonZero s -> Term s (PValue 'Sorted 'NonZero))
-> (Term
      s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
    -> PValue 'Sorted 'NonZero s)
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term s (PValue 'Sorted 'NonZero)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term
  s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> PValue 'Sorted 'NonZero s
forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S).
Term s (PMap keys PCurrencySymbol (PMap keys PTokenName PInteger))
-> PValue keys amounts s
PValue
      (Term
   s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
 -> Term s (PValue 'Sorted 'NonZero))
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term s (PValue 'Sorted 'NonZero)
forall a b. (a -> b) -> a -> b
$ Term
  s
  (PMap Any PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
   :--> PMap
          'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
forall (k :: PType) (v :: PType) (any :: KeyGuarantees) (s :: S).
(POrd k, PIsData k) =>
Term s (PMap any k v :--> PMap 'Sorted k v)
AssocMap.passertSorted Term
  s
  (PMap Any PCurrencySymbol (PMap 'Sorted PTokenName PInteger)
   :--> PMap
          'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term
     s (PMap Any PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
#$ Term
  s (PMap anyKey PCurrencySymbol (PMap anyKey PTokenName PInteger))
-> Term
     s (PMap Any PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
forall (b :: PType) (a :: PType) (s :: S). Term s a -> Term s b
punsafeCoerce
      (Term
   s (PMap anyKey PCurrencySymbol (PMap anyKey PTokenName PInteger))
 -> Term
      s (PMap Any PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
-> Term
     s (PMap anyKey PCurrencySymbol (PMap anyKey PTokenName PInteger))
-> Term
     s (PMap Any PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
forall a b. (a -> b) -> a -> b
$ Term s (PValue anyKey anyAmount)
-> Term s (PInner (PValue anyKey anyAmount))
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto Term s (PValue anyKey anyAmount)
value

{- | Test if the value contains nothing but Ada

@since 2.1.1
-}
pisAdaOnlyValue ::
  forall (s :: S).
  Term s (PValue 'AssocMap.Sorted 'Positive :--> PBool)
pisAdaOnlyValue :: forall (s :: S). Term s (PValue 'Sorted 'Positive :--> PBool)
pisAdaOnlyValue = (forall (s :: S). Term s (PValue 'Sorted 'Positive :--> PBool))
-> Term s (PValue 'Sorted 'Positive :--> PBool)
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic ((forall (s :: S). Term s (PValue 'Sorted 'Positive :--> PBool))
 -> Term s (PValue 'Sorted 'Positive :--> PBool))
-> (forall (s :: S). Term s (PValue 'Sorted 'Positive :--> PBool))
-> Term s (PValue 'Sorted 'Positive :--> PBool)
forall a b. (a -> b) -> a -> b
$
  (Term s (PValue 'Sorted 'Positive) -> Term s PBool)
-> Term s (PValue 'Sorted 'Positive :--> PBool)
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s PBool) -> Term s (c :--> PBool)
plam ((Term s (PValue 'Sorted 'Positive) -> Term s PBool)
 -> Term s (PValue 'Sorted 'Positive :--> PBool))
-> (Term s (PValue 'Sorted 'Positive) -> Term s PBool)
-> Term s (PValue 'Sorted 'Positive :--> PBool)
forall a b. (a -> b) -> a -> b
$ \Term s (PValue 'Sorted 'Positive)
value ->
    Term
  s
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol)
        (PAsData (PMap 'Sorted PTokenName PInteger))))
-> (PBuiltinList
      (PBuiltinPair
         (PAsData PCurrencySymbol)
         (PAsData (PMap 'Sorted PTokenName PInteger)))
      s
    -> Term s PBool)
-> Term s PBool
forall (a :: PType) (s :: S) (b :: PType).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch (Term
  s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term
     s
     (PInner
        (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto (Term
   s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
 -> Term
      s
      (PInner
         (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))))
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term
     s
     (PInner
        (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
forall a b. (a -> b) -> a -> b
$ Term s (PValue 'Sorted 'Positive)
-> Term s (PInner (PValue 'Sorted 'Positive))
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto Term s (PValue 'Sorted 'Positive)
value) ((PBuiltinList
    (PBuiltinPair
       (PAsData PCurrencySymbol)
       (PAsData (PMap 'Sorted PTokenName PInteger)))
    s
  -> Term s PBool)
 -> Term s PBool)
-> (PBuiltinList
      (PBuiltinPair
         (PAsData PCurrencySymbol)
         (PAsData (PMap 'Sorted PTokenName PInteger)))
      s
    -> Term s PBool)
-> Term s PBool
forall a b. (a -> b) -> a -> b
$ \case
      PBuiltinList
  (PBuiltinPair
     (PAsData PCurrencySymbol)
     (PAsData (PMap 'Sorted PTokenName PInteger)))
  s
PNil -> PBool s -> Term s PBool
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon PBool s
forall (s :: S). PBool s
PTrue
      PCons Term
  s
  (PBuiltinPair
     (PAsData PCurrencySymbol)
     (PAsData (PMap 'Sorted PTokenName PInteger)))
x Term
  s
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol)
        (PAsData (PMap 'Sorted PTokenName PInteger))))
xs -> Term s (PBool :--> (PBool :--> PBool))
forall (s :: S). Term s (PBool :--> (PBool :--> PBool))
pand' Term s (PBool :--> (PBool :--> PBool))
-> Term s PBool -> Term s (PBool :--> PBool)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# (Term
  s
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol)
        (PAsData (PMap 'Sorted PTokenName PInteger)))
   :--> PBool)
forall (a :: PType) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (PBuiltinList a :--> PBool)
forall (list :: PType -> PType) (a :: PType) (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (list a :--> PBool)
pnull Term
  s
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol)
        (PAsData (PMap 'Sorted PTokenName PInteger)))
   :--> PBool)
-> Term
     s
     (PBuiltinList
        (PBuiltinPair
           (PAsData PCurrencySymbol)
           (PAsData (PMap 'Sorted PTokenName PInteger))))
-> Term s PBool
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term
  s
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol)
        (PAsData (PMap 'Sorted PTokenName PInteger))))
xs) Term s (PBool :--> PBool) -> Term s PBool -> Term s PBool
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# (Term
  s
  (PBuiltinPair
     (PAsData PCurrencySymbol)
     (PAsData (PMap 'Sorted PTokenName PInteger))
   :--> PAsData PCurrencySymbol)
forall (s :: S) (a :: PType) (b :: PType).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term
  s
  (PBuiltinPair
     (PAsData PCurrencySymbol)
     (PAsData (PMap 'Sorted PTokenName PInteger))
   :--> PAsData PCurrencySymbol)
-> Term
     s
     (PBuiltinPair
        (PAsData PCurrencySymbol)
        (PAsData (PMap 'Sorted PTokenName PInteger)))
-> Term s (PAsData PCurrencySymbol)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term
  s
  (PBuiltinPair
     (PAsData PCurrencySymbol)
     (PAsData (PMap 'Sorted PTokenName PInteger)))
x Term s (PAsData PCurrencySymbol)
-> Term s (PAsData PCurrencySymbol) -> Term s PBool
forall (s :: S).
Term s (PAsData PCurrencySymbol)
-> Term s (PAsData PCurrencySymbol) -> Term s PBool
forall (t :: PType) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s (PAsData PCurrencySymbol)
forall (s :: S). Term s (PAsData PCurrencySymbol)
padaSymbolData)

{- | Strip all non-Ada from a 'PValue'.

@since 2.1.1
-}
padaOnlyValue ::
  forall (v :: AmountGuarantees) (s :: S).
  Term s (PValue 'AssocMap.Sorted v :--> PValue 'AssocMap.Sorted v)
padaOnlyValue :: forall (v :: AmountGuarantees) (s :: S).
Term s (PValue 'Sorted v :--> PValue 'Sorted v)
padaOnlyValue = ClosedTerm (PValue 'Sorted v :--> PValue 'Sorted v)
-> Term s (PValue 'Sorted v :--> PValue 'Sorted v)
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm (PValue 'Sorted v :--> PValue 'Sorted v)
 -> Term s (PValue 'Sorted v :--> PValue 'Sorted v))
-> ClosedTerm (PValue 'Sorted v :--> PValue 'Sorted v)
-> Term s (PValue 'Sorted v :--> PValue 'Sorted v)
forall a b. (a -> b) -> a -> b
$
  (Term s (PValue 'Sorted v) -> Term s (PValue 'Sorted v))
-> Term s (PValue 'Sorted v :--> PValue 'Sorted v)
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s (PValue 'Sorted v))
-> Term s (c :--> PValue 'Sorted v)
plam ((Term s (PValue 'Sorted v) -> Term s (PValue 'Sorted v))
 -> Term s (PValue 'Sorted v :--> PValue 'Sorted v))
-> (Term s (PValue 'Sorted v) -> Term s (PValue 'Sorted v))
-> Term s (PValue 'Sorted v :--> PValue 'Sorted v)
forall a b. (a -> b) -> a -> b
$ \Term s (PValue 'Sorted v)
value ->
    Term
  s
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol)
        (PAsData (PMap 'Sorted PTokenName PInteger))))
-> (PBuiltinList
      (PBuiltinPair
         (PAsData PCurrencySymbol)
         (PAsData (PMap 'Sorted PTokenName PInteger)))
      s
    -> Term s (PValue 'Sorted v))
-> Term s (PValue 'Sorted v)
forall (a :: PType) (s :: S) (b :: PType).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch (Term
  s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term
     s
     (PInner
        (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto (Term
   s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
 -> Term
      s
      (PInner
         (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))))
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term
     s
     (PInner
        (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
forall a b. (a -> b) -> a -> b
$ Term s (PValue 'Sorted v) -> Term s (PInner (PValue 'Sorted v))
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto Term s (PValue 'Sorted v)
value) ((PBuiltinList
    (PBuiltinPair
       (PAsData PCurrencySymbol)
       (PAsData (PMap 'Sorted PTokenName PInteger)))
    s
  -> Term s (PValue 'Sorted v))
 -> Term s (PValue 'Sorted v))
-> (PBuiltinList
      (PBuiltinPair
         (PAsData PCurrencySymbol)
         (PAsData (PMap 'Sorted PTokenName PInteger)))
      s
    -> Term s (PValue 'Sorted v))
-> Term s (PValue 'Sorted v)
forall a b. (a -> b) -> a -> b
$ \case
      PBuiltinList
  (PBuiltinPair
     (PAsData PCurrencySymbol)
     (PAsData (PMap 'Sorted PTokenName PInteger)))
  s
PNil -> Term s (PValue 'Sorted v)
value
      PCons Term
  s
  (PBuiltinPair
     (PAsData PCurrencySymbol)
     (PAsData (PMap 'Sorted PTokenName PInteger)))
x Term
  s
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol)
        (PAsData (PMap 'Sorted PTokenName PInteger))))
_ ->
        Term
  s
  (PBool
   :--> (PValue 'Sorted v
         :--> (PValue 'Sorted v :--> PValue 'Sorted v)))
forall (a :: PType) (s :: S).
Term s (PBool :--> (a :--> (a :--> a)))
pif'
          # (pfstBuiltin # x #== padaSymbolData)
          # pcon (PValue $ pcon $ AssocMap.PMap $ PPrelude.psingleton # x)
          # pcon (PValue AssocMap.pempty)

{- | Strip all Ada from a 'PValue'.

@since 2.1.1
-}
pnoAdaValue ::
  forall (v :: AmountGuarantees) (s :: S).
  Term s (PValue 'AssocMap.Sorted v :--> PValue 'AssocMap.Sorted v)
pnoAdaValue :: forall (v :: AmountGuarantees) (s :: S).
Term s (PValue 'Sorted v :--> PValue 'Sorted v)
pnoAdaValue = ClosedTerm (PValue 'Sorted v :--> PValue 'Sorted v)
-> Term s (PValue 'Sorted v :--> PValue 'Sorted v)
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm (PValue 'Sorted v :--> PValue 'Sorted v)
 -> Term s (PValue 'Sorted v :--> PValue 'Sorted v))
-> ClosedTerm (PValue 'Sorted v :--> PValue 'Sorted v)
-> Term s (PValue 'Sorted v :--> PValue 'Sorted v)
forall a b. (a -> b) -> a -> b
$
  (Term s (PValue 'Sorted v) -> Term s (PValue 'Sorted v))
-> Term s (PValue 'Sorted v :--> PValue 'Sorted v)
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s (PValue 'Sorted v))
-> Term s (c :--> PValue 'Sorted v)
plam ((Term s (PValue 'Sorted v) -> Term s (PValue 'Sorted v))
 -> Term s (PValue 'Sorted v :--> PValue 'Sorted v))
-> (Term s (PValue 'Sorted v) -> Term s (PValue 'Sorted v))
-> Term s (PValue 'Sorted v :--> PValue 'Sorted v)
forall a b. (a -> b) -> a -> b
$ \Term s (PValue 'Sorted v)
value ->
    Term
  s
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol)
        (PAsData (PMap 'Sorted PTokenName PInteger))))
-> (PBuiltinList
      (PBuiltinPair
         (PAsData PCurrencySymbol)
         (PAsData (PMap 'Sorted PTokenName PInteger)))
      s
    -> Term s (PValue 'Sorted v))
-> Term s (PValue 'Sorted v)
forall (a :: PType) (s :: S) (b :: PType).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch (Term
  s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term
     s
     (PInner
        (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto (Term
   s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
 -> Term
      s
      (PInner
         (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))))
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> Term
     s
     (PInner
        (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
forall a b. (a -> b) -> a -> b
$ Term s (PValue 'Sorted v) -> Term s (PInner (PValue 'Sorted v))
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto Term s (PValue 'Sorted v)
value) ((PBuiltinList
    (PBuiltinPair
       (PAsData PCurrencySymbol)
       (PAsData (PMap 'Sorted PTokenName PInteger)))
    s
  -> Term s (PValue 'Sorted v))
 -> Term s (PValue 'Sorted v))
-> (PBuiltinList
      (PBuiltinPair
         (PAsData PCurrencySymbol)
         (PAsData (PMap 'Sorted PTokenName PInteger)))
      s
    -> Term s (PValue 'Sorted v))
-> Term s (PValue 'Sorted v)
forall a b. (a -> b) -> a -> b
$ \case
      PBuiltinList
  (PBuiltinPair
     (PAsData PCurrencySymbol)
     (PAsData (PMap 'Sorted PTokenName PInteger)))
  s
PNil -> Term s (PValue 'Sorted v)
value
      PCons Term
  s
  (PBuiltinPair
     (PAsData PCurrencySymbol)
     (PAsData (PMap 'Sorted PTokenName PInteger)))
x Term
  s
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol)
        (PAsData (PMap 'Sorted PTokenName PInteger))))
xs -> Term
  s
  (PBool
   :--> (PValue 'Sorted v
         :--> (PValue 'Sorted v :--> PValue 'Sorted v)))
forall (a :: PType) (s :: S).
Term s (PBool :--> (a :--> (a :--> a)))
pif' Term
  s
  (PBool
   :--> (PValue 'Sorted v
         :--> (PValue 'Sorted v :--> PValue 'Sorted v)))
-> Term s PBool
-> Term
     s (PValue 'Sorted v :--> (PValue 'Sorted v :--> PValue 'Sorted v))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# (Term
  s
  (PBuiltinPair
     (PAsData PCurrencySymbol)
     (PAsData (PMap 'Sorted PTokenName PInteger))
   :--> PAsData PCurrencySymbol)
forall (s :: S) (a :: PType) (b :: PType).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term
  s
  (PBuiltinPair
     (PAsData PCurrencySymbol)
     (PAsData (PMap 'Sorted PTokenName PInteger))
   :--> PAsData PCurrencySymbol)
-> Term
     s
     (PBuiltinPair
        (PAsData PCurrencySymbol)
        (PAsData (PMap 'Sorted PTokenName PInteger)))
-> Term s (PAsData PCurrencySymbol)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term
  s
  (PBuiltinPair
     (PAsData PCurrencySymbol)
     (PAsData (PMap 'Sorted PTokenName PInteger)))
x Term s (PAsData PCurrencySymbol)
-> Term s (PAsData PCurrencySymbol) -> Term s PBool
forall (s :: S).
Term s (PAsData PCurrencySymbol)
-> Term s (PAsData PCurrencySymbol) -> Term s PBool
forall (t :: PType) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s (PAsData PCurrencySymbol)
forall (s :: S). Term s (PAsData PCurrencySymbol)
padaSymbolData) Term
  s (PValue 'Sorted v :--> (PValue 'Sorted v :--> PValue 'Sorted v))
-> Term s (PValue 'Sorted v)
-> Term s (PValue 'Sorted v :--> PValue 'Sorted v)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# PValue 'Sorted v s -> Term s (PValue 'Sorted v)
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (Term
  s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> PValue 'Sorted v s
forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S).
Term s (PMap keys PCurrencySymbol (PMap keys PTokenName PInteger))
-> PValue keys amounts s
PValue (Term
   s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
 -> PValue 'Sorted v s)
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
-> PValue 'Sorted v s
forall a b. (a -> b) -> a -> b
$ PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger) s
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger) s
 -> Term
      s
      (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger)))
-> PMap
     'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger) s
-> Term
     s (PMap 'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger))
forall a b. (a -> b) -> a -> b
$ Term
  s
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol)
        (PAsData (PMap 'Sorted PTokenName PInteger))))
-> PMap
     'Sorted PCurrencySymbol (PMap 'Sorted PTokenName PInteger) s
forall (keysort :: KeyGuarantees) (k :: PType) (v :: PType)
       (s :: S).
Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> PMap keysort k v s
AssocMap.PMap Term
  s
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol)
        (PAsData (PMap 'Sorted PTokenName PInteger))))
xs) Term s (PValue 'Sorted v :--> PValue 'Sorted v)
-> Term s (PValue 'Sorted v) -> Term s (PValue 'Sorted v)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PValue 'Sorted v)
value

-- Helpers

zeroData :: forall (s :: S). Term s (PAsData PInteger)
zeroData :: forall (s :: S). Term s (PAsData PInteger)
zeroData = Term s PInteger -> Term s (PAsData PInteger)
forall (a :: PType) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata Term s PInteger
0

-- Applies a function to every amount in the map.
pmapAmounts ::
  forall (k :: AssocMap.KeyGuarantees) (a :: AmountGuarantees) (s :: S).
  Term s ((PInteger :--> PInteger) :--> PValue k a :--> PValue k 'NoGuarantees)
pmapAmounts :: forall (k :: KeyGuarantees) (a :: AmountGuarantees) (s :: S).
Term
  s
  ((PInteger :--> PInteger)
   :--> (PValue k a :--> PValue k 'NoGuarantees))
pmapAmounts = ClosedTerm
  ((PInteger :--> PInteger)
   :--> (PValue k a :--> PValue k 'NoGuarantees))
-> Term
     s
     ((PInteger :--> PInteger)
      :--> (PValue k a :--> PValue k 'NoGuarantees))
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   ((PInteger :--> PInteger)
    :--> (PValue k a :--> PValue k 'NoGuarantees))
 -> Term
      s
      ((PInteger :--> PInteger)
       :--> (PValue k a :--> PValue k 'NoGuarantees)))
-> ClosedTerm
     ((PInteger :--> PInteger)
      :--> (PValue k a :--> PValue k 'NoGuarantees))
-> Term
     s
     ((PInteger :--> PInteger)
      :--> (PValue k a :--> PValue k 'NoGuarantees))
forall a b. (a -> b) -> a -> b
$
  (Term s (PInteger :--> PInteger)
 -> Term s (PValue k a) -> Term s (PValue k 'NoGuarantees))
-> Term
     s
     ((PInteger :--> PInteger)
      :--> (PValue k a :--> PValue k 'NoGuarantees))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c
 -> Term s (PValue k a) -> Term s (PValue k 'NoGuarantees))
-> Term s (c :--> (PValue k a :--> PValue k 'NoGuarantees))
plam ((Term s (PInteger :--> PInteger)
  -> Term s (PValue k a) -> Term s (PValue k 'NoGuarantees))
 -> Term
      s
      ((PInteger :--> PInteger)
       :--> (PValue k a :--> PValue k 'NoGuarantees)))
-> (Term s (PInteger :--> PInteger)
    -> Term s (PValue k a) -> Term s (PValue k 'NoGuarantees))
-> Term
     s
     ((PInteger :--> PInteger)
      :--> (PValue k a :--> PValue k 'NoGuarantees))
forall a b. (a -> b) -> a -> b
$
    \Term s (PInteger :--> PInteger)
f Term s (PValue k a)
v -> PValue k 'NoGuarantees s -> Term s (PValue k 'NoGuarantees)
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PValue k 'NoGuarantees s -> Term s (PValue k 'NoGuarantees))
-> PValue k 'NoGuarantees s -> Term s (PValue k 'NoGuarantees)
forall a b. (a -> b) -> a -> b
$ Term s (PMap k PCurrencySymbol (PMap k PTokenName PInteger))
-> PValue k 'NoGuarantees s
forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees)
       (s :: S).
Term s (PMap keys PCurrencySymbol (PMap keys PTokenName PInteger))
-> PValue keys amounts s
PValue (Term s (PMap k PCurrencySymbol (PMap k PTokenName PInteger))
 -> PValue k 'NoGuarantees s)
-> Term s (PMap k PCurrencySymbol (PMap k PTokenName PInteger))
-> PValue k 'NoGuarantees s
forall a b. (a -> b) -> a -> b
$ Term
  s
  ((PMap k PTokenName PInteger :--> PMap k PTokenName PInteger)
   :--> (PMap k PCurrencySymbol (PMap k PTokenName PInteger)
         :--> PMap k PCurrencySymbol (PMap k PTokenName PInteger)))
forall (g :: KeyGuarantees) (k :: PType) (a :: PType) (b :: PType)
       (s :: S).
(PIsData a, PIsData b) =>
Term s ((a :--> b) :--> (PMap g k a :--> PMap g k b))
AssocMap.pmap Term
  s
  ((PMap k PTokenName PInteger :--> PMap k PTokenName PInteger)
   :--> (PMap k PCurrencySymbol (PMap k PTokenName PInteger)
         :--> PMap k PCurrencySymbol (PMap k PTokenName PInteger)))
-> Term
     s (PMap k PTokenName PInteger :--> PMap k PTokenName PInteger)
-> Term
     s
     (PMap k PCurrencySymbol (PMap k PTokenName PInteger)
      :--> PMap k PCurrencySymbol (PMap k PTokenName PInteger))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s (PMap k PTokenName PInteger)
 -> Term s (PMap k PTokenName PInteger))
-> Term
     s (PMap k PTokenName PInteger :--> PMap k PTokenName PInteger)
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s (PMap k PTokenName PInteger))
-> Term s (c :--> PMap k PTokenName PInteger)
plam (Term
  s
  ((PInteger :--> PInteger)
   :--> (PMap k PTokenName PInteger :--> PMap k PTokenName PInteger))
forall (g :: KeyGuarantees) (k :: PType) (a :: PType) (b :: PType)
       (s :: S).
(PIsData a, PIsData b) =>
Term s ((a :--> b) :--> (PMap g k a :--> PMap g k b))
AssocMap.pmap Term
  s
  ((PInteger :--> PInteger)
   :--> (PMap k PTokenName PInteger :--> PMap k PTokenName PInteger))
-> Term s (PInteger :--> PInteger)
-> Term
     s (PMap k PTokenName PInteger :--> PMap k PTokenName PInteger)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PInteger :--> PInteger)
f Term s (PMap k PTokenName PInteger :--> PMap k PTokenName PInteger)
-> Term s (PMap k PTokenName PInteger)
-> Term s (PMap k PTokenName PInteger)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
#) Term
  s
  (PMap k PCurrencySymbol (PMap k PTokenName PInteger)
   :--> PMap k PCurrencySymbol (PMap k PTokenName PInteger))
-> Term s (PMap k PCurrencySymbol (PMap k PTokenName PInteger))
-> Term s (PMap k PCurrencySymbol (PMap k PTokenName PInteger))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PValue k a) -> Term s (PInner (PValue k a))
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto Term s (PValue k a)
v

passertNonZero ::
  forall (kg :: AssocMap.KeyGuarantees) (ag :: AmountGuarantees).
  ( forall (s :: S). Term s (PValue kg ag :--> PValue kg 'NonZero)
  )
passertNonZero :: forall (kg :: KeyGuarantees) (ag :: AmountGuarantees) (s :: S).
Term s (PValue kg ag :--> PValue kg 'NonZero)
passertNonZero = (Term s (PValue kg ag) -> Term s (PValue kg 'NonZero))
-> Term s (PValue kg ag :--> PValue kg 'NonZero)
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s (PValue kg 'NonZero))
-> Term s (c :--> PValue kg 'NonZero)
plam ((Term s (PValue kg ag) -> Term s (PValue kg 'NonZero))
 -> Term s (PValue kg ag :--> PValue kg 'NonZero))
-> (Term s (PValue kg ag) -> Term s (PValue kg 'NonZero))
-> Term s (PValue kg ag :--> PValue kg 'NonZero)
forall a b. (a -> b) -> a -> b
$ \Term s (PValue kg ag)
val ->
  Term s PBool
-> Term s (PValue kg 'NonZero)
-> Term s (PValue kg 'NonZero)
-> Term s (PValue kg 'NonZero)
forall (a :: PType) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif (Term
  s
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol) (PAsData (PMap kg PTokenName PInteger)))
   :--> PBool)
forall (s' :: S) (k :: KeyGuarantees).
Term
  s'
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
   :--> PBool)
outer Term
  s
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol) (PAsData (PMap kg PTokenName PInteger)))
   :--> PBool)
-> Term
     s
     (PBuiltinList
        (PBuiltinPair
           (PAsData PCurrencySymbol) (PAsData (PMap kg PTokenName PInteger))))
-> Term s PBool
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
#$ Term s (PMap kg PCurrencySymbol (PMap kg PTokenName PInteger))
-> Term
     s
     (PBuiltinList
        (PBuiltinPair
           (PAsData PCurrencySymbol) (PAsData (PMap kg PTokenName PInteger))))
Term s (PMap kg PCurrencySymbol (PMap kg PTokenName PInteger))
-> Term
     s (PInner (PMap kg PCurrencySymbol (PMap kg PTokenName PInteger)))
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto (Term s (PMap kg PCurrencySymbol (PMap kg PTokenName PInteger))
 -> Term
      s
      (PBuiltinList
         (PBuiltinPair
            (PAsData PCurrencySymbol)
            (PAsData (PMap kg PTokenName PInteger)))))
-> (Term s (PValue kg ag)
    -> Term s (PMap kg PCurrencySymbol (PMap kg PTokenName PInteger)))
-> Term s (PValue kg ag)
-> Term
     s
     (PBuiltinList
        (PBuiltinPair
           (PAsData PCurrencySymbol) (PAsData (PMap kg PTokenName PInteger))))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PValue kg ag) -> Term s (PInner (PValue kg ag))
Term s (PValue kg ag)
-> Term s (PMap kg PCurrencySymbol (PMap kg PTokenName PInteger))
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto (Term s (PValue kg ag)
 -> Term
      s
      (PBuiltinList
         (PBuiltinPair
            (PAsData PCurrencySymbol)
            (PAsData (PMap kg PTokenName PInteger)))))
-> Term s (PValue kg ag)
-> Term
     s
     (PBuiltinList
        (PBuiltinPair
           (PAsData PCurrencySymbol) (PAsData (PMap kg PTokenName PInteger))))
forall a b. (a -> b) -> a -> b
$ Term s (PValue kg ag)
val) (Term s (PValue kg ag) -> Term s (PValue kg 'NonZero)
forall (b :: PType) (a :: PType) (s :: S). Term s a -> Term s b
punsafeCoerce Term s (PValue kg ag)
val) (Term s PString -> Term s (PValue kg 'NonZero)
forall (a :: PType) (s :: S). Term s PString -> Term s a
ptraceInfoError Term s PString
"Zero amount in Value")
  where
    outer ::
      forall (s' :: S) (k :: AssocMap.KeyGuarantees).
      Term s' (PBuiltinList (PBuiltinPair (PAsData PCurrencySymbol) (PAsData (AssocMap.PMap k PTokenName PInteger))) :--> PBool)
    outer :: forall (s' :: S) (k :: KeyGuarantees).
Term
  s'
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
   :--> PBool)
outer = Term
  s'
  (((PBuiltinList
       (PBuiltinPair
          (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
     :--> PBool)
    :--> (PBuiltinList
            (PBuiltinPair
               (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
          :--> PBool))
   :--> (PBuiltinList
           (PBuiltinPair
              (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
         :--> PBool))
forall (s :: S) (a :: PType) (b :: PType).
Term s (((a :--> b) :--> (a :--> b)) :--> (a :--> b))
pfix Term
  s'
  (((PBuiltinList
       (PBuiltinPair
          (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
     :--> PBool)
    :--> (PBuiltinList
            (PBuiltinPair
               (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
          :--> PBool))
   :--> (PBuiltinList
           (PBuiltinPair
              (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
         :--> PBool))
-> Term
     s'
     ((PBuiltinList
         (PBuiltinPair
            (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
       :--> PBool)
      :--> (PBuiltinList
              (PBuiltinPair
                 (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
            :--> PBool))
-> Term
     s'
     (PBuiltinList
        (PBuiltinPair
           (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
      :--> PBool)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
#$ (Term
   s'
   (PBuiltinList
      (PBuiltinPair
         (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
    :--> PBool)
 -> Term
      s'
      (PBuiltinList
         (PBuiltinPair
            (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger))))
 -> Term s' PBool)
-> Term
     s'
     ((PBuiltinList
         (PBuiltinPair
            (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
       :--> PBool)
      :--> (PBuiltinList
              (PBuiltinPair
                 (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
            :--> PBool))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s' c
 -> Term
      s'
      (PBuiltinList
         (PBuiltinPair
            (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger))))
 -> Term s' PBool)
-> Term
     s'
     (c
      :--> (PBuiltinList
              (PBuiltinPair
                 (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
            :--> PBool))
plam ((Term
    s'
    (PBuiltinList
       (PBuiltinPair
          (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
     :--> PBool)
  -> Term
       s'
       (PBuiltinList
          (PBuiltinPair
             (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger))))
  -> Term s' PBool)
 -> Term
      s'
      ((PBuiltinList
          (PBuiltinPair
             (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
        :--> PBool)
       :--> (PBuiltinList
               (PBuiltinPair
                  (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
             :--> PBool)))
-> (Term
      s'
      (PBuiltinList
         (PBuiltinPair
            (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
       :--> PBool)
    -> Term
         s'
         (PBuiltinList
            (PBuiltinPair
               (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger))))
    -> Term s' PBool)
-> Term
     s'
     ((PBuiltinList
         (PBuiltinPair
            (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
       :--> PBool)
      :--> (PBuiltinList
              (PBuiltinPair
                 (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
            :--> PBool))
forall a b. (a -> b) -> a -> b
$ \Term
  s'
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
   :--> PBool)
self Term
  s'
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger))))
m ->
      Term
  s'
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger))))
-> (PBuiltinList
      (PBuiltinPair
         (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
      s'
    -> Term s' PBool)
-> Term s' PBool
forall (a :: PType) (s :: S) (b :: PType).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term
  s'
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger))))
m ((PBuiltinList
    (PBuiltinPair
       (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
    s'
  -> Term s' PBool)
 -> Term s' PBool)
-> (PBuiltinList
      (PBuiltinPair
         (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
      s'
    -> Term s' PBool)
-> Term s' PBool
forall a b. (a -> b) -> a -> b
$ \case
        PCons Term
  s'
  (PBuiltinPair
     (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
x Term
  s'
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger))))
xs -> Term
  s'
  (PBuiltinList
     (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
   :--> PBool)
ClosedTerm
  (PBuiltinList
     (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
   :--> PBool)
inner Term
  s'
  (PBuiltinList
     (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
   :--> PBool)
-> Term
     s'
     (PBuiltinList
        (PBuiltinPair (PAsData PTokenName) (PAsData PInteger)))
-> Term s' PBool
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s' (PMap k PTokenName PInteger)
-> Term
     s'
     (PBuiltinList
        (PBuiltinPair (PAsData PTokenName) (PAsData PInteger)))
Term s' (PMap k PTokenName PInteger)
-> Term s' (PInner (PMap k PTokenName PInteger))
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto (Term s' (PMap k PTokenName PInteger)
 -> Term
      s'
      (PBuiltinList
         (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))))
-> (Term s' (PAsData (PMap k PTokenName PInteger))
    -> Term s' (PMap k PTokenName PInteger))
-> Term s' (PAsData (PMap k PTokenName PInteger))
-> Term
     s'
     (PBuiltinList
        (PBuiltinPair (PAsData PTokenName) (PAsData PInteger)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s' (PAsData (PMap k PTokenName PInteger))
-> Term s' (PMap k PTokenName PInteger)
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s' (PAsData (PMap k PTokenName PInteger))
 -> Term
      s'
      (PBuiltinList
         (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))))
-> Term s' (PAsData (PMap k PTokenName PInteger))
-> Term
     s'
     (PBuiltinList
        (PBuiltinPair (PAsData PTokenName) (PAsData PInteger)))
forall a b. (a -> b) -> a -> b
$ Term
  s'
  (PBuiltinPair
     (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger))
   :--> PAsData (PMap k PTokenName PInteger))
forall (s :: S) (a :: PType) (b :: PType).
Term s (PBuiltinPair a b :--> b)
psndBuiltin Term
  s'
  (PBuiltinPair
     (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger))
   :--> PAsData (PMap k PTokenName PInteger))
-> Term
     s'
     (PBuiltinPair
        (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
-> Term s' (PAsData (PMap k PTokenName PInteger))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term
  s'
  (PBuiltinPair
     (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
x) Term s' PBool -> Term s' PBool -> Term s' PBool
forall (s :: S). Term s PBool -> Term s PBool -> Term s PBool
#&& Term
  s'
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
   :--> PBool)
self Term
  s'
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
   :--> PBool)
-> Term
     s'
     (PBuiltinList
        (PBuiltinPair
           (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger))))
-> Term s' PBool
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term
  s'
  (PBuiltinList
     (PBuiltinPair
        (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger))))
xs
        PBuiltinList
  (PBuiltinPair
     (PAsData PCurrencySymbol) (PAsData (PMap k PTokenName PInteger)))
  s'
PNil -> PBool s' -> Term s' PBool
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon PBool s'
forall (s :: S). PBool s
PTrue
    inner :: ClosedTerm (PBuiltinList (PBuiltinPair (PAsData PTokenName) (PAsData PInteger)) :--> PBool)
    inner :: ClosedTerm
  (PBuiltinList
     (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
   :--> PBool)
inner = Term
  s
  (((PBuiltinList
       (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
     :--> PBool)
    :--> (PBuiltinList
            (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
          :--> PBool))
   :--> (PBuiltinList
           (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
         :--> PBool))
forall (s :: S) (a :: PType) (b :: PType).
Term s (((a :--> b) :--> (a :--> b)) :--> (a :--> b))
pfix Term
  s
  (((PBuiltinList
       (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
     :--> PBool)
    :--> (PBuiltinList
            (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
          :--> PBool))
   :--> (PBuiltinList
           (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
         :--> PBool))
-> Term
     s
     ((PBuiltinList
         (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
       :--> PBool)
      :--> (PBuiltinList
              (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
            :--> PBool))
-> Term
     s
     (PBuiltinList
        (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
      :--> PBool)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
#$ (Term
   s
   (PBuiltinList
      (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
    :--> PBool)
 -> Term
      s
      (PBuiltinList
         (PBuiltinPair (PAsData PTokenName) (PAsData PInteger)))
 -> Term s PBool)
-> Term
     s
     ((PBuiltinList
         (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
       :--> PBool)
      :--> (PBuiltinList
              (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
            :--> PBool))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c
 -> Term
      s
      (PBuiltinList
         (PBuiltinPair (PAsData PTokenName) (PAsData PInteger)))
 -> Term s PBool)
-> Term
     s
     (c
      :--> (PBuiltinList
              (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
            :--> PBool))
plam ((Term
    s
    (PBuiltinList
       (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
     :--> PBool)
  -> Term
       s
       (PBuiltinList
          (PBuiltinPair (PAsData PTokenName) (PAsData PInteger)))
  -> Term s PBool)
 -> Term
      s
      ((PBuiltinList
          (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
        :--> PBool)
       :--> (PBuiltinList
               (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
             :--> PBool)))
-> (Term
      s
      (PBuiltinList
         (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
       :--> PBool)
    -> Term
         s
         (PBuiltinList
            (PBuiltinPair (PAsData PTokenName) (PAsData PInteger)))
    -> Term s PBool)
-> Term
     s
     ((PBuiltinList
         (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
       :--> PBool)
      :--> (PBuiltinList
              (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
            :--> PBool))
forall a b. (a -> b) -> a -> b
$ \Term
  s
  (PBuiltinList
     (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
   :--> PBool)
self Term
  s
  (PBuiltinList
     (PBuiltinPair (PAsData PTokenName) (PAsData PInteger)))
m ->
      Term
  s
  (PBuiltinList
     (PBuiltinPair (PAsData PTokenName) (PAsData PInteger)))
-> (PBuiltinList
      (PBuiltinPair (PAsData PTokenName) (PAsData PInteger)) s
    -> Term s PBool)
-> Term s PBool
forall (a :: PType) (s :: S) (b :: PType).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term
  s
  (PBuiltinList
     (PBuiltinPair (PAsData PTokenName) (PAsData PInteger)))
m ((PBuiltinList
    (PBuiltinPair (PAsData PTokenName) (PAsData PInteger)) s
  -> Term s PBool)
 -> Term s PBool)
-> (PBuiltinList
      (PBuiltinPair (PAsData PTokenName) (PAsData PInteger)) s
    -> Term s PBool)
-> Term s PBool
forall a b. (a -> b) -> a -> b
$ \case
        PCons Term s (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
x Term
  s
  (PBuiltinList
     (PBuiltinPair (PAsData PTokenName) (PAsData PInteger)))
xs -> Term s (PBool :--> PBool)
forall (s :: S). Term s (PBool :--> PBool)
pnot Term s (PBool :--> PBool) -> Term s PBool -> Term s PBool
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# (Term
  s
  (PBuiltinPair (PAsData PTokenName) (PAsData PInteger)
   :--> PAsData PInteger)
forall (s :: S) (a :: PType) (b :: PType).
Term s (PBuiltinPair a b :--> b)
psndBuiltin Term
  s
  (PBuiltinPair (PAsData PTokenName) (PAsData PInteger)
   :--> PAsData PInteger)
-> Term s (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
-> Term s (PAsData PInteger)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
x Term s (PAsData PInteger)
-> Term s (PAsData PInteger) -> Term s PBool
forall (s :: S).
Term s (PAsData PInteger)
-> Term s (PAsData PInteger) -> Term s PBool
forall (t :: PType) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== forall (a :: PType) (s :: S).
PLiftable a =>
AsHaskell a -> Term s a
pconstant @(PAsData PInteger) Integer
AsHaskell (PAsData PInteger)
0) Term s PBool -> Term s PBool -> Term s PBool
forall (s :: S). Term s PBool -> Term s PBool -> Term s PBool
#&& Term
  s
  (PBuiltinList
     (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
   :--> PBool)
self Term
  s
  (PBuiltinList
     (PBuiltinPair (PAsData PTokenName) (PAsData PInteger))
   :--> PBool)
-> Term
     s
     (PBuiltinList
        (PBuiltinPair (PAsData PTokenName) (PAsData PInteger)))
-> Term s PBool
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term
  s
  (PBuiltinList
     (PBuiltinPair (PAsData PTokenName) (PAsData PInteger)))
xs
        PBuiltinList
  (PBuiltinPair (PAsData PTokenName) (PAsData PInteger)) s
PNil -> PBool s -> Term s PBool
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon PBool s
forall (s :: S). PBool s
PTrue