| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Plutarch.LedgerApi.Utils
Description
Useful tools that aren't part of the Plutarch API per se, but get used in multiple places.
Synopsis
- newtype Mret (a :: S -> Type) (s :: S) = Mret (Term s a)
- data PMaybeData (a :: S -> Type) (s :: S)
- data PRationalData s = PRationalData {
- prationalData'numerator :: Term s (PAsData PInteger)
- prationalData'denominator :: Term s (PAsData PPositive)
- data PSBool (s :: S)
- pfromDJust :: forall (a :: S -> Type) (s :: S). PIsData a => Term s (PMaybeData a :--> a)
- pisDJust :: forall (a :: S -> Type) (s :: S). Term s (PMaybeData a :--> PBool)
- pmaybeData :: forall (a :: S -> Type) (b :: S -> Type) (s :: S). PIsData a => Term s (b :--> ((a :--> b) :--> (PMaybeData a :--> b)))
- pdjust :: forall (a :: S -> Type) (s :: S). PIsData a => Term s (a :--> PMaybeData a)
- pdnothing :: forall (a :: S -> Type) (s :: S). Term s (PMaybeData a)
- pmaybeToMaybeData :: forall (a :: S -> Type) (s :: S). PIsData a => Term s (PMaybe a :--> PMaybeData a)
- pmaybeDataToMaybe :: forall (a :: S -> Type) (s :: S). PIsData a => Term s (PMaybeData a :--> PMaybe a)
- passertPDJust :: forall (a :: S -> Type) (s :: S). PIsData a => Term s (PString :--> (PMaybeData a :--> a))
- pmapMaybeData :: forall (a :: S -> Type) (b :: S -> Type) (s :: S). Term s ((PAsData a :--> PAsData b) :--> (PMaybeData a :--> PMaybeData b))
- prationalFromData :: ClosedTerm (PRationalData :--> PRational)
- pmatchStrict :: forall (r :: S -> Type) (s :: S). Term s PSBool -> (PSBool s -> Term s r) -> Term s r
- pstrue :: forall (s :: S). Term s PSBool
- psfalse :: forall (s :: S). Term s PSBool
- psif :: forall (s :: S) (a :: S -> Type). Term s PSBool -> Term s a -> Term s a -> Term s a
- psif' :: forall (s :: S) (a :: S -> Type). Term s PSBool -> Term s a -> Term s a -> Term s a
- psnot :: forall (s :: S). Term s PSBool -> Term s PSBool
- psand :: forall (s :: S). Term s PSBool -> Term s PSBool -> Term s PSBool
- psand' :: forall (s :: S). Term s PSBool -> Term s PSBool -> Term s PSBool
- psor :: forall (s :: S). Term s PSBool -> Term s PSBool -> Term s PSBool
- psor' :: forall (s :: S). Term s PSBool -> Term s PSBool -> Term s PSBool
Types
newtype Mret (a :: S -> Type) (s :: S) Source #
Term, but with its type arguments flipped. This is a useful helper for
defining PTryFrom instances.
For example, consider the PTryFrom instance for PTokenName:
instance PTryFrom PData (PAsData PTokenName) where type PTryFromExcess PData (PAsData PTokenName) = Mret PTokenName
We need to do this because PTryFromExcess expects something of kind S ->
Type, but Term has kind S -> (S -> Type) -> Type, which doesn't quite
fit. By using Mret, we end up with something of kind (S -> Type)
-> S -> Type, which fits.
The name is just Term written backwards.
Since: 2.0.0
Constructors
| Mret (Term s a) |
data PMaybeData (a :: S -> Type) (s :: S) Source #
Since: 3.3.0
Instances
| PEq (PMaybeData a) Source # | Since: 2.0.0 |
Defined in Plutarch.LedgerApi.Utils Methods (#==) :: forall (s :: S). Term s (PMaybeData a) -> Term s (PMaybeData a) -> Term s PBool | |
| PIsData (PMaybeData a) Source # | Since: 3.3.0 |
Defined in Plutarch.LedgerApi.Utils Methods pfromDataImpl :: forall (s :: S). Term s (PAsData (PMaybeData a)) -> Term s (PMaybeData a) pdataImpl :: forall (s :: S). Term s (PMaybeData a) -> Term s PData | |
| (ToData (AsHaskell a), FromData (AsHaskell a)) => PLiftable (PMaybeData a) Source # | |
Defined in Plutarch.LedgerApi.Utils Methods haskToRepr :: AsHaskell (PMaybeData a) -> PlutusRepr (PMaybeData a) reprToHask :: PlutusRepr (PMaybeData a) -> Either LiftError (AsHaskell (PMaybeData a)) reprToPlut :: forall (s :: S). PlutusRepr (PMaybeData a) -> PLifted s (PMaybeData a) plutToRepr :: (forall (s :: S). PLifted s (PMaybeData a)) -> Either LiftError (PlutusRepr (PMaybeData a)) | |
| (PIsData a, POrd a) => POrd (PMaybeData a) Source # | Since: 2.0.0 |
Defined in Plutarch.LedgerApi.Utils Methods (#<=) :: forall (s :: S). Term s (PMaybeData a) -> Term s (PMaybeData a) -> Term s PBool (#<) :: forall (s :: S). Term s (PMaybeData a) -> Term s (PMaybeData a) -> Term s PBool pmax :: forall (s :: S). Term s (PMaybeData a) -> Term s (PMaybeData a) -> Term s (PMaybeData a) pmin :: forall (s :: S). Term s (PMaybeData a) -> Term s (PMaybeData a) -> Term s (PMaybeData a) | |
| PlutusType (PMaybeData a) Source # | |
Defined in Plutarch.LedgerApi.Utils Associated Types type PInner (PMaybeData a) :: PType type PCovariant' (PMaybeData a) type PContravariant' (PMaybeData a) type PVariant' (PMaybeData a) Methods pcon' :: forall (s :: S). PMaybeData a s -> Term s (PInner (PMaybeData a)) pmatch' :: forall (s :: S) (b :: PType). Term s (PInner (PMaybeData a)) -> (PMaybeData a s -> Term s b) -> Term s b | |
| (PIsData a, PShow a) => PShow (PMaybeData a) Source # | Since: 2.0.0 |
Defined in Plutarch.LedgerApi.Utils Methods pshow' :: forall (s :: S). Bool -> Term s (PMaybeData a) -> Term s PString | |
| Generic (PMaybeData a s) Source # | |
Defined in Plutarch.LedgerApi.Utils Methods from :: PMaybeData a s -> Rep (PMaybeData a s) x Source # to :: Rep (PMaybeData a s) x -> PMaybeData a s Source # | |
| Generic (PMaybeData a s) Source # | |
Defined in Plutarch.LedgerApi.Utils Associated Types type Code (PMaybeData a s) :: [[Type]] | |
| type AsHaskell (PMaybeData a) Source # | Since: 3.3.0 |
Defined in Plutarch.LedgerApi.Utils type AsHaskell (PMaybeData a) = AsHaskell (DeriveDataPLiftable (PMaybeData a) (Maybe (AsHaskell a))) | |
| type PlutusRepr (PMaybeData a) Source # | |
Defined in Plutarch.LedgerApi.Utils type PlutusRepr (PMaybeData a) = PlutusRepr (DeriveDataPLiftable (PMaybeData a) (Maybe (AsHaskell a))) | |
| type PContravariant' (PMaybeData a) Source # | |
Defined in Plutarch.LedgerApi.Utils | |
| type PCovariant' (PMaybeData a) Source # | |
Defined in Plutarch.LedgerApi.Utils | |
| type PInner (PMaybeData a) Source # | Since: 3.3.0 |
Defined in Plutarch.LedgerApi.Utils | |
| type PVariant' (PMaybeData a) Source # | |
Defined in Plutarch.LedgerApi.Utils | |
| type Rep (PMaybeData a s) Source # | Since: 2.0.0 |
Defined in Plutarch.LedgerApi.Utils type Rep (PMaybeData a s) = D1 ('MetaData "PMaybeData" "Plutarch.LedgerApi.Utils" "plutarch-ledger-api-3.3.0-4jQI9F1PNF98cchtG9eex0" 'False) (C1 ('MetaCons "PDJust" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Term s (PAsData a)))) :+: C1 ('MetaCons "PDNothing" 'PrefixI 'False) (U1 :: Type -> Type)) | |
| type Code (PMaybeData a s) Source # | Since: 3.3.0 |
Defined in Plutarch.LedgerApi.Utils | |
data PRationalData s Source #
A Rational type that corresponds to the data encoding used by Rational.
Since: 3.1.0
Constructors
| PRationalData | |
Fields
| |
Instances
| PEq PRationalData Source # | Since: 3.1.0 |
Defined in Plutarch.LedgerApi.Utils Methods (#==) :: forall (s :: S). Term s PRationalData -> Term s PRationalData -> Term s PBool | |
| PIsData PRationalData Source # | Since: 3.1.0 |
Defined in Plutarch.LedgerApi.Utils Methods pfromDataImpl :: forall (s :: S). Term s (PAsData PRationalData) -> Term s PRationalData pdataImpl :: forall (s :: S). Term s PRationalData -> Term s PData | |
| PLiftable PRationalData Source # | |
Defined in Plutarch.LedgerApi.Utils Methods haskToRepr :: AsHaskell PRationalData -> PlutusRepr PRationalData reprToHask :: PlutusRepr PRationalData -> Either LiftError (AsHaskell PRationalData) reprToPlut :: forall (s :: S). PlutusRepr PRationalData -> PLifted s PRationalData plutToRepr :: (forall (s :: S). PLifted s PRationalData) -> Either LiftError (PlutusRepr PRationalData) | |
| POrd PRationalData Source # | Since: 3.1.0 |
Defined in Plutarch.LedgerApi.Utils Methods (#<=) :: forall (s :: S). Term s PRationalData -> Term s PRationalData -> Term s PBool (#<) :: forall (s :: S). Term s PRationalData -> Term s PRationalData -> Term s PBool pmax :: forall (s :: S). Term s PRationalData -> Term s PRationalData -> Term s PRationalData pmin :: forall (s :: S). Term s PRationalData -> Term s PRationalData -> Term s PRationalData | |
| PlutusType PRationalData Source # | |
Defined in Plutarch.LedgerApi.Utils Associated Types type PInner PRationalData :: PType type PCovariant' PRationalData type PContravariant' PRationalData type PVariant' PRationalData Methods pcon' :: forall (s :: S). PRationalData s -> Term s (PInner PRationalData) pmatch' :: forall (s :: S) (b :: PType). Term s (PInner PRationalData) -> (PRationalData s -> Term s b) -> Term s b | |
| PShow PRationalData Source # | Since: 3.1.0 |
Defined in Plutarch.LedgerApi.Utils Methods pshow' :: forall (s :: S). Bool -> Term s PRationalData -> Term s PString | |
| Generic (PRationalData s) Source # | |
Defined in Plutarch.LedgerApi.Utils Methods from :: PRationalData s -> Rep (PRationalData s) x Source # to :: Rep (PRationalData s) x -> PRationalData s Source # | |
| Generic (PRationalData s) Source # | |
Defined in Plutarch.LedgerApi.Utils Associated Types type Code (PRationalData s) :: [[Type]] Methods from :: PRationalData s -> Rep (PRationalData s) to :: Rep (PRationalData s) -> PRationalData s | |
| type AsHaskell PRationalData Source # | Since: 3.3.0 |
Defined in Plutarch.LedgerApi.Utils | |
| type PlutusRepr PRationalData Source # | |
Defined in Plutarch.LedgerApi.Utils | |
| type PContravariant' PRationalData Source # | |
Defined in Plutarch.LedgerApi.Utils | |
| type PCovariant' PRationalData Source # | |
Defined in Plutarch.LedgerApi.Utils | |
| type PInner PRationalData Source # | Since: 3.3.0 |
Defined in Plutarch.LedgerApi.Utils | |
| type PVariant' PRationalData Source # | |
Defined in Plutarch.LedgerApi.Utils | |
| type Rep (PRationalData s) Source # | Since: 3.1.0 |
Defined in Plutarch.LedgerApi.Utils type Rep (PRationalData s) = D1 ('MetaData "PRationalData" "Plutarch.LedgerApi.Utils" "plutarch-ledger-api-3.3.0-4jQI9F1PNF98cchtG9eex0" 'False) (C1 ('MetaCons "PRationalData" 'PrefixI 'True) (S1 ('MetaSel ('Just "prationalData'numerator") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Term s (PAsData PInteger))) :*: S1 ('MetaSel ('Just "prationalData'denominator") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Term s (PAsData PPositive))))) | |
| type Code (PRationalData s) Source # | Since: 3.3.0 |
Defined in Plutarch.LedgerApi.Utils | |
Scott-encoded boolean.
Since: 3.3.0
Instances
| PlutusType PSBool Source # | Since: 3.3.0 |
Defined in Plutarch.LedgerApi.Utils | |
| Show (PSBool s) Source # | Since: 3.3.0 |
| Eq (PSBool s) Source # | Since: 3.3.0 |
| Ord (PSBool s) Source # | Since: 3.3.0 |
Defined in Plutarch.LedgerApi.Utils | |
| type PContravariant' PSBool Source # | |
Defined in Plutarch.LedgerApi.Utils | |
| type PCovariant' PSBool Source # | |
Defined in Plutarch.LedgerApi.Utils | |
| type PInner PSBool Source # | |
Defined in Plutarch.LedgerApi.Utils type PInner PSBool | |
| type PVariant' PSBool Source # | |
Defined in Plutarch.LedgerApi.Utils | |
Functions
PMaybeData
pfromDJust :: forall (a :: S -> Type) (s :: S). PIsData a => Term s (PMaybeData a :--> a) Source #
pisDJust :: forall (a :: S -> Type) (s :: S). Term s (PMaybeData a :--> PBool) Source #
Yield PTrue if a given PMaybeData is of the form .PDJust _
Since: 2.1.1
pmaybeData :: forall (a :: S -> Type) (b :: S -> Type) (s :: S). PIsData a => Term s (b :--> ((a :--> b) :--> (PMaybeData a :--> b))) Source #
Special version of pmaybe that works with PMaybeData.
Since: 2.1.1
pdjust :: forall (a :: S -> Type) (s :: S). PIsData a => Term s (a :--> PMaybeData a) Source #
Construct a PDJust value.
Since: 2.1.1
pdnothing :: forall (a :: S -> Type) (s :: S). Term s (PMaybeData a) Source #
Construct a PDNothing value.
Since: 2.1.1
pmaybeToMaybeData :: forall (a :: S -> Type) (s :: S). PIsData a => Term s (PMaybe a :--> PMaybeData a) Source #
Construct a PMaybeData given a PMaybe. Could be useful if you want to
"lift" from PMaybe to Maybe.
Since: 2.1.1
pmaybeDataToMaybe :: forall (a :: S -> Type) (s :: S). PIsData a => Term s (PMaybeData a :--> PMaybe a) Source #
Inverse of pmaybeToMaybeData
Since: 3.3.0
passertPDJust :: forall (a :: S -> Type) (s :: S). PIsData a => Term s (PString :--> (PMaybeData a :--> a)) Source #
Extract the value stored in a PMaybeData container. If there's no value,
throw an error with the given message.
Since: 2.1.1
pmapMaybeData :: forall (a :: S -> Type) (b :: S -> Type) (s :: S). Term s ((PAsData a :--> PAsData b) :--> (PMaybeData a :--> PMaybeData b)) Source #
Since: 3.3.0
PRationalData
prationalFromData :: ClosedTerm (PRationalData :--> PRational) Source #
Since: 3.1.0
PSBool
pmatchStrict :: forall (r :: S -> Type) (s :: S). Term s PSBool -> (PSBool s -> Term s r) -> Term s r Source #
Strict version of pmatch for PSBool.
Since: 3.3.0
psif :: forall (s :: S) (a :: S -> Type). Term s PSBool -> Term s a -> Term s a -> Term s a Source #
Lazy if on Scott-encoded bool.
Since: 3.3.0
psif' :: forall (s :: S) (a :: S -> Type). Term s PSBool -> Term s a -> Term s a -> Term s a Source #
Strict if on Scott-encoded bool.
Since: 3.3.0
psnot :: forall (s :: S). Term s PSBool -> Term s PSBool Source #
not on Scott-encoded bool.
Since: 3.3.0
psand :: forall (s :: S). Term s PSBool -> Term s PSBool -> Term s PSBool Source #
Lazy AND on Scott-encoded bool.
psand' :: forall (s :: S). Term s PSBool -> Term s PSBool -> Term s PSBool Source #
Strict AND on Scott-encoded bool.
Since: 3.3.0