plutarch-ledger-api-3.2.1
Safe HaskellSafe-Inferred
LanguageHaskell2010

Plutarch.LedgerApi.Utils

Description

Useful tools that aren't part of the Plutarch API per se, but get used in multiple places.

Synopsis

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) 

Instances

Instances details
Generic (Mret a s) Source # 
Instance details

Defined in Plutarch.LedgerApi.Utils

Associated Types

type Rep (Mret a s) :: Type -> Type Source #

Methods

from :: Mret a s -> Rep (Mret a s) x Source #

to :: Rep (Mret a s) x -> Mret a s Source #

type Rep (Mret a s) Source #

Since: 2.0.0

Instance details

Defined in Plutarch.LedgerApi.Utils

type Rep (Mret a s) = D1 ('MetaData "Mret" "Plutarch.LedgerApi.Utils" "plutarch-ledger-api-3.2.1-6pZLN6XlvMZ4r7ZEuopoAx" 'True) (C1 ('MetaCons "Mret" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Term s a))))

data PMaybeData (a :: S -> Type) (s :: S) Source #

@since WIP

Constructors

PDJust (Term s (PAsData a)) 
PDNothing 

Instances

Instances details
PTryFrom PData a => PTryFrom PData (PAsData (PMaybeData a)) Source #

Since: 2.0.0

Instance details

Defined in Plutarch.LedgerApi.Utils

Associated Types

type PTryFromExcess PData (PAsData (PMaybeData a)) :: PType

Methods

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

Instance details

Defined in Plutarch.LedgerApi.Utils

Associated Types

type PTryFromExcess PData (PMaybeData a) :: PType

Methods

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

Instance details

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

PEq (PMaybeData a) Source #

Since: 2.0.0

Instance details

Defined in Plutarch.LedgerApi.Utils

Methods

(#==) :: forall (s :: S). Term s (PMaybeData a) -> Term s (PMaybeData a) -> Term s PBool

(ToData (AsHaskell a), FromData (AsHaskell a)) => PLiftable (PMaybeData a) Source # 
Instance details

Defined in Plutarch.LedgerApi.Utils

Associated Types

type AsHaskell (PMaybeData a)

type PlutusRepr (PMaybeData a)

Methods

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

Instance details

Defined in Plutarch.LedgerApi.Utils

Methods

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

Instance details

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

(#>=) :: 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

Instance details

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

Instance details

Defined in Plutarch.LedgerApi.Utils

Methods

pshow' :: forall (s :: S). Bool -> Term s (PMaybeData a) -> Term s PString

Generic (PMaybeData a s) Source # 
Instance details

Defined in Plutarch.LedgerApi.Utils

Associated Types

type Rep (PMaybeData a s) :: Type -> Type Source #

Methods

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 # 
Instance details

Defined in Plutarch.LedgerApi.Utils

type PTryFromExcess PData (PAsData (PMaybeData a)) = PTryFromExcess PData (PInner (PAsData (PMaybeData a)))
type PTryFromExcess PData (PMaybeData a) Source # 
Instance details

Defined in Plutarch.LedgerApi.Utils

type PTryFromExcess PData (PMaybeData a) = PTryFromExcess PData (PInner (PMaybeData a))
type AsHaskell (PMaybeData a) Source #

@since WIP

Instance details

Defined in Plutarch.LedgerApi.Utils

type AsHaskell (PMaybeData a) = AsHaskell (DeriveDataPLiftable (PMaybeData a) (Maybe (AsHaskell a)))
type PlutusRepr (PMaybeData a) Source # 
Instance details

Defined in Plutarch.LedgerApi.Utils

type PlutusRepr (PMaybeData a) = PlutusRepr (DeriveDataPLiftable (PMaybeData a) (Maybe (AsHaskell a)))
type PContravariant' (PMaybeData a) Source # 
Instance details

Defined in Plutarch.LedgerApi.Utils

type PContravariant' (PMaybeData a) = All2 PContravariant'' (PCode (PMaybeData a))
type PCovariant' (PMaybeData a) Source # 
Instance details

Defined in Plutarch.LedgerApi.Utils

type PCovariant' (PMaybeData a) = All2 PCovariant'' (PCode (PMaybeData a))
type PInner (PMaybeData a) Source # 
Instance details

Defined in Plutarch.LedgerApi.Utils

type PInner (PMaybeData a) = PData
type PVariant' (PMaybeData a) Source # 
Instance details

Defined in Plutarch.LedgerApi.Utils

type PVariant' (PMaybeData a) = All2 PVariant'' (PCode (PMaybeData a))
type Rep (PMaybeData a s) Source #

Since: 2.0.0

Instance details

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

Constructors

PRationalData (Term s (PDataRecord '["numerator" ':= PInteger, "denominator" ':= PPositive])) 

Instances

Instances details
PIsData PRationalData Source #

Since: 3.1.0

Instance details

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

PDataFields PRationalData Source # 
Instance details

Defined in Plutarch.LedgerApi.Utils

Associated Types

type PFields PRationalData :: [PLabeledType]

Methods

ptoFields :: forall (s :: S). Term s PRationalData -> Term s (PDataRecord (PFields PRationalData))

PEq PRationalData Source #

Since: 3.1.0

Instance details

Defined in Plutarch.LedgerApi.Utils

Methods

(#==) :: forall (s :: S). Term s PRationalData -> Term s PRationalData -> Term s PBool

PLiftable PRationalData Source # 
Instance details

Defined in Plutarch.LedgerApi.Utils

Associated Types

type AsHaskell PRationalData

type PlutusRepr PRationalData

Methods

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

Instance details

Defined in Plutarch.LedgerApi.Utils

Methods

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

Instance details

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

(#>=) :: 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

Instance details

Defined in Plutarch.LedgerApi.Utils

Associated Types

type DPTStrat PRationalData

PlutusType PRationalData Source # 
Instance details

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

Instance details

Defined in Plutarch.LedgerApi.Utils

Methods

pshow' :: forall (s :: S). Bool -> Term s PRationalData -> Term s PString

PTryFrom PData PRationalData Source #

Since: 3.1.0

Instance details

Defined in Plutarch.LedgerApi.Utils

Associated Types

type PTryFromExcess PData PRationalData :: PType

Methods

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

Instance details

Defined in Plutarch.LedgerApi.Utils

Associated Types

type PTryFromExcess PData (PAsData PRationalData) :: PType

Methods

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 # 
Instance details

Defined in Plutarch.LedgerApi.Utils

Associated Types

type Rep (PRationalData s) :: Type -> Type Source #

type PFields PRationalData Source #

Since: 3.1.0

Instance details

Defined in Plutarch.LedgerApi.Utils

type PFields PRationalData = Helper (PInner PRationalData)
type AsHaskell PRationalData Source #

@since WIP

Instance details

Defined in Plutarch.LedgerApi.Utils

type AsHaskell PRationalData = AsHaskell (DeriveDataPLiftable PRationalData Rational)
type PlutusRepr PRationalData Source # 
Instance details

Defined in Plutarch.LedgerApi.Utils

type PlutusRepr PRationalData = PlutusRepr (DeriveDataPLiftable PRationalData Rational)
type DPTStrat PRationalData Source # 
Instance details

Defined in Plutarch.LedgerApi.Utils

type DPTStrat PRationalData = PlutusTypeData
type PContravariant' PRationalData Source # 
Instance details

Defined in Plutarch.LedgerApi.Utils

type PContravariant' PRationalData = All2 PContravariant'' (PCode PRationalData)
type PCovariant' PRationalData Source # 
Instance details

Defined in Plutarch.LedgerApi.Utils

type PCovariant' PRationalData = All2 PCovariant'' (PCode PRationalData)
type PInner PRationalData Source #

Since: 3.1.0

Instance details

Defined in Plutarch.LedgerApi.Utils

type PInner PRationalData = DerivedPInner (DPTStrat PRationalData) PRationalData
type PVariant' PRationalData Source # 
Instance details

Defined in Plutarch.LedgerApi.Utils

type PVariant' PRationalData = All2 PVariant'' (PCode PRationalData)
type PTryFromExcess PData PRationalData Source # 
Instance details

Defined in Plutarch.LedgerApi.Utils

type PTryFromExcess PData PRationalData = Mret PPositive
type PTryFromExcess PData (PAsData PRationalData) Source # 
Instance details

Defined in Plutarch.LedgerApi.Utils

type PTryFromExcess PData (PAsData PRationalData) = Mret PPositive
type Rep (PRationalData s) Source #

Since: 3.1.0

Instance details

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])))))

data PSBool (s :: S) Source #

Scott-encoded boolean.

@since WIP

Constructors

PSTrue 
PSFalse 

Instances

Instances details
PlutusType PSBool Source #

@since WIP

Instance details

Defined in Plutarch.LedgerApi.Utils

Associated Types

type PInner PSBool :: PType

type PCovariant' PSBool

type PContravariant' PSBool

type PVariant' PSBool

Methods

pcon' :: forall (s :: S). PSBool s -> Term s (PInner PSBool)

pmatch' :: forall (s :: S) (b :: PType). Term s (PInner PSBool) -> (PSBool s -> Term s b) -> Term s b

Show (PSBool s) Source #

@since WIP

Instance details

Defined in Plutarch.LedgerApi.Utils

Eq (PSBool s) Source #

@since WIP

Instance details

Defined in Plutarch.LedgerApi.Utils

Methods

(==) :: PSBool s -> PSBool s -> Bool Source #

(/=) :: PSBool s -> PSBool s -> Bool Source #

Ord (PSBool s) Source #

@since WIP

Instance details

Defined in Plutarch.LedgerApi.Utils

Methods

compare :: PSBool s -> PSBool s -> Ordering Source #

(<) :: PSBool s -> PSBool s -> Bool Source #

(<=) :: PSBool s -> PSBool s -> Bool Source #

(>) :: PSBool s -> PSBool s -> Bool Source #

(>=) :: PSBool s -> PSBool s -> Bool Source #

max :: PSBool s -> PSBool s -> PSBool s Source #

min :: PSBool s -> PSBool s -> PSBool s Source #

type PContravariant' PSBool Source # 
Instance details

Defined in Plutarch.LedgerApi.Utils

type PContravariant' PSBool = All2 PContravariant'' (PCode PSBool)
type PCovariant' PSBool Source # 
Instance details

Defined in Plutarch.LedgerApi.Utils

type PCovariant' PSBool = All2 PCovariant'' (PCode PSBool)
type PInner PSBool Source # 
Instance details

Defined in Plutarch.LedgerApi.Utils

type PInner PSBool
type PVariant' PSBool Source # 
Instance details

Defined in Plutarch.LedgerApi.Utils

type PVariant' PSBool = All2 PVariant'' (PCode PSBool)

Functions

PMaybeData

pfromDJust :: forall (a :: S -> Type) (s :: S). PIsData a => Term s (PMaybeData a :--> a) Source #

Extracts the element out of a PDJust and throws an error if its argument is PDNothing.

Since: 2.1.1

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

pstrue :: forall (s :: S). Term s PSBool Source #

@since WIP

psfalse :: forall (s :: S). Term s PSBool Source #

@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

psor :: forall (s :: S). Term s PSBool -> Term s PSBool -> Term s PSBool Source #

Lazy OR on Scott-encoded bool

@since WIP

psor' :: forall (s :: S). Term s PSBool -> Term s PSBool -> Term s PSBool Source #

Strict OR on Scott-encoded bool.

@since WIP