Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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)
- newtype PRationalData s = PRationalData (Term s (PDataRecord '["numerator" ':= PInteger, "denominator" ':= 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))
- 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
Mret (Term s a) |
data PMaybeData (a :: S -> Type) (s :: S) Source #
@since WIP
Instances
PTryFrom PData a => PTryFrom PData (PAsData (PMaybeData a)) Source # | Since: 2.0.0 |
Defined in Plutarch.LedgerApi.Utils type PTryFromExcess PData (PAsData (PMaybeData a)) :: PType ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PAsData (PMaybeData a)), Reduce (PTryFromExcess PData (PAsData (PMaybeData a)) s)) -> Term s r) -> Term s r | |
PTryFrom PData a => PTryFrom PData (PMaybeData a) Source # | Since: 2.0.0 |
Defined in Plutarch.LedgerApi.Utils type PTryFromExcess PData (PMaybeData a) :: PType ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PMaybeData a), Reduce (PTryFromExcess PData (PMaybeData a) s)) -> Term s r) -> Term s r | |
PIsData (PMaybeData a) Source # | @since WIP |
Defined in Plutarch.LedgerApi.Utils pfromDataImpl :: forall (s :: S). Term s (PAsData (PMaybeData a)) -> Term s (PMaybeData a) pdataImpl :: forall (s :: S). Term s (PMaybeData a) -> Term s PData | |
PEq (PMaybeData a) Source # | Since: 2.0.0 |
Defined in Plutarch.LedgerApi.Utils (#==) :: forall (s :: S). Term s (PMaybeData a) -> Term s (PMaybeData a) -> Term s PBool | |
(ToData (AsHaskell a), FromData (AsHaskell a)) => PLiftable (PMaybeData a) Source # | |
Defined in Plutarch.LedgerApi.Utils type AsHaskell (PMaybeData a) type PlutusRepr (PMaybeData a) toPlutarchRepr :: AsHaskell (PMaybeData a) -> PlutusRepr (PMaybeData a) toPlutarch :: forall (s :: S). AsHaskell (PMaybeData a) -> PLifted s (PMaybeData a) fromPlutarchRepr :: PlutusRepr (PMaybeData a) -> Maybe (AsHaskell (PMaybeData a)) fromPlutarch :: (forall (s :: S). PLifted s (PMaybeData a)) -> Either LiftError (AsHaskell (PMaybeData a)) | |
(PIsData a, PPartialOrd a) => POrd (PMaybeData a) Source # | Since: 2.0.0 |
Defined in Plutarch.LedgerApi.Utils 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) | |
(PIsData a, PPartialOrd a) => PPartialOrd (PMaybeData a) Source # | Since: 2.0.0 |
Defined in Plutarch.LedgerApi.Utils (#<=) :: 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 (#>=) :: 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 | |
PlutusType (PMaybeData a) Source # | @since WIP |
Defined in Plutarch.LedgerApi.Utils type PInner (PMaybeData a) :: PType type PCovariant' (PMaybeData a) type PContravariant' (PMaybeData a) type PVariant' (PMaybeData a) 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 pshow' :: forall (s :: S). Bool -> Term s (PMaybeData a) -> Term s PString | |
Generic (PMaybeData a s) Source # | |
Defined in Plutarch.LedgerApi.Utils from :: PMaybeData a s -> Rep (PMaybeData a s) x Source # to :: Rep (PMaybeData a s) x -> PMaybeData a s Source # | |
type PTryFromExcess PData (PAsData (PMaybeData a)) Source # | |
Defined in Plutarch.LedgerApi.Utils type PTryFromExcess PData (PAsData (PMaybeData a)) = PTryFromExcess PData (PInner (PAsData (PMaybeData a))) | |
type PTryFromExcess PData (PMaybeData a) Source # | |
Defined in Plutarch.LedgerApi.Utils | |
type AsHaskell (PMaybeData a) Source # | @since WIP |
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 # | |
Defined in Plutarch.LedgerApi.Utils type PInner (PMaybeData a) = PData | |
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.2.1-6pZLN6XlvMZ4r7ZEuopoAx" '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)) |
newtype PRationalData s Source #
A Rational type that corresponds to the data encoding used by Rational
.
Since: 3.1.0
PRationalData (Term s (PDataRecord '["numerator" ':= PInteger, "denominator" ':= PPositive])) |
Instances
PIsData PRationalData Source # | Since: 3.1.0 |
Defined in Plutarch.LedgerApi.Utils pfromDataImpl :: forall (s :: S). Term s (PAsData PRationalData) -> Term s PRationalData pdataImpl :: forall (s :: S). Term s PRationalData -> Term s PData | |
PDataFields PRationalData Source # | |
Defined in Plutarch.LedgerApi.Utils type PFields PRationalData :: [PLabeledType] ptoFields :: forall (s :: S). Term s PRationalData -> Term s (PDataRecord (PFields PRationalData)) | |
PEq PRationalData Source # | Since: 3.1.0 |
Defined in Plutarch.LedgerApi.Utils (#==) :: forall (s :: S). Term s PRationalData -> Term s PRationalData -> Term s PBool | |
PLiftable PRationalData Source # | |
Defined in Plutarch.LedgerApi.Utils type AsHaskell PRationalData type PlutusRepr PRationalData toPlutarchRepr :: AsHaskell PRationalData -> PlutusRepr PRationalData toPlutarch :: forall (s :: S). AsHaskell PRationalData -> PLifted s PRationalData fromPlutarchRepr :: PlutusRepr PRationalData -> Maybe (AsHaskell PRationalData) fromPlutarch :: (forall (s :: S). PLifted s PRationalData) -> Either LiftError (AsHaskell PRationalData) | |
POrd PRationalData Source # | Since: 3.1.0 |
Defined in Plutarch.LedgerApi.Utils 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 | |
PPartialOrd PRationalData Source # | Since: 3.1.0 |
Defined in Plutarch.LedgerApi.Utils (#<=) :: forall (s :: S). Term s PRationalData -> Term s PRationalData -> Term s PBool (#<) :: forall (s :: S). Term s PRationalData -> Term s PRationalData -> Term s PBool (#>=) :: forall (s :: S). Term s PRationalData -> Term s PRationalData -> Term s PBool (#>) :: forall (s :: S). Term s PRationalData -> Term s PRationalData -> Term s PBool | |
DerivePlutusType PRationalData Source # | Since: 3.1.0 |
Defined in Plutarch.LedgerApi.Utils type DPTStrat PRationalData | |
PlutusType PRationalData Source # | |
Defined in Plutarch.LedgerApi.Utils type PInner PRationalData :: PType type PCovariant' PRationalData type PContravariant' PRationalData type PVariant' PRationalData 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 pshow' :: forall (s :: S). Bool -> Term s PRationalData -> Term s PString | |
PTryFrom PData PRationalData Source # | Since: 3.1.0 |
Defined in Plutarch.LedgerApi.Utils type PTryFromExcess PData PRationalData :: PType ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s PRationalData, Reduce (PTryFromExcess PData PRationalData s)) -> Term s r) -> Term s r | |
PTryFrom PData (PAsData PRationalData) Source # | This instance produces a verified positive denominator as the excess output. Since: 3.1.0 |
Defined in Plutarch.LedgerApi.Utils type PTryFromExcess PData (PAsData PRationalData) :: PType ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PAsData PRationalData), Reduce (PTryFromExcess PData (PAsData PRationalData) s)) -> Term s r) -> Term s r | |
Generic (PRationalData s) Source # | |
Defined in Plutarch.LedgerApi.Utils from :: PRationalData s -> Rep (PRationalData s) x Source # to :: Rep (PRationalData s) x -> PRationalData s Source # | |
type PFields PRationalData Source # | Since: 3.1.0 |
Defined in Plutarch.LedgerApi.Utils | |
type AsHaskell PRationalData Source # | @since WIP |
Defined in Plutarch.LedgerApi.Utils | |
type PlutusRepr PRationalData Source # | |
Defined in Plutarch.LedgerApi.Utils | |
type DPTStrat PRationalData Source # | |
Defined in Plutarch.LedgerApi.Utils type DPTStrat PRationalData = PlutusTypeData | |
type PContravariant' PRationalData Source # | |
Defined in Plutarch.LedgerApi.Utils | |
type PCovariant' PRationalData Source # | |
Defined in Plutarch.LedgerApi.Utils | |
type PInner PRationalData Source # | Since: 3.1.0 |
Defined in Plutarch.LedgerApi.Utils | |
type PVariant' PRationalData Source # | |
Defined in Plutarch.LedgerApi.Utils | |
type PTryFromExcess PData PRationalData Source # | |
Defined in Plutarch.LedgerApi.Utils | |
type PTryFromExcess PData (PAsData 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.2.1-6pZLN6XlvMZ4r7ZEuopoAx" 'True) (C1 ('MetaCons "PRationalData" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Term s (PDataRecord '["numerator" ':= PInteger, "denominator" ':= PPositive]))))) |
Scott-encoded boolean.
@since WIP
Instances
PlutusType PSBool Source # | @since WIP |
Show (PSBool s) Source # | @since WIP |
Eq (PSBool s) Source # | @since WIP |
Ord (PSBool s) Source # | @since WIP |
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 WIP
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
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 WIP
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 WIP
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 WIP
psnot :: forall (s :: S). Term s PSBool -> Term s PSBool Source #
not
on Scott-encoded bool.
@since WIP
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 WIP