cardano-ledger-core-1.22.0.0: Core components of Cardano ledgers from the Shelley release on.
Safe HaskellNone
LanguageHaskell2010

Cardano.Ledger.Plutus.ExUnits

Synopsis

Documentation

txscriptfee ∷ Prices → ExUnits → Coin Source #

Compute the cost of a script based upon prices and the number of execution units.

pointWiseExUnits ∷ (Natural → Natural → Bool) → ExUnits → ExUnits → Bool Source #

It is deliberate that there is no Ord instance for ExUnits. Use this function to compare if one ExUnit is pointwise compareable to another. In case when Ord instance like comparison is necessary you can use zipSemiExUnits compare, or the OrdExUnits newtype defined below.

zipSemiExUnits ∷ Semigroup a ⇒ (Natural → Natural → a) → ExUnits → ExUnits → a Source #

Pointwise combine units into a semigroup and mappened the results.

newtype ExUnits Source #

This newtype wrapper of ExUnits' is used to hide an implementation detail inside the ExUnits pattern.

Constructors

WrapExUnits 

Bundled Patterns

pattern ExUnits ∷ Natural → Natural → ExUnits

Arbitrary execution unit in which we measure the cost of scripts in terms of space in memory and execution time.

This pattern hides the fact that ExUnits' is parametric in the underlying type. The ledger itself uses ExUnits Natural' exclusively.

We would have preferred to use a type alias for ExUnits Natural', but this is not possible: https://gitlab.haskell.org/ghc/ghc/-/issues/19507.

Instances

Instances details
FromJSON ExUnits Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

ToJSON ExUnits Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

DecCBOR ExUnits Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

EncCBOR ExUnits Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

ToPlutusData ExUnits Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ToPlutusData

NFData ExUnits Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Methods

rnf ∷ ExUnits → () #

Monoid ExUnits Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Semigroup ExUnits Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Methods

(<>) ∷ ExUnits → ExUnits → ExUnits #

sconcat ∷ NonEmpty ExUnits → ExUnits #

stimes ∷ Integral b ⇒ b → ExUnits → ExUnits #

Generic ExUnits Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Associated Types

type Rep ExUnits 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

type Rep ExUnits = D1 ('MetaData "ExUnits" "Cardano.Ledger.Plutus.ExUnits" "cardano-ledger-core-1.22.0.0-inplace" 'True) (C1 ('MetaCons "WrapExUnits" 'PrefixI 'True) (S1 ('MetaSel ('Just "unWrapExUnits") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ExUnits' Natural))))

Methods

from ∷ ExUnits → Rep ExUnits x #

to ∷ Rep ExUnits x → ExUnits #

Show ExUnits Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Methods

showsPrec ∷ Int → ExUnits → ShowS #

show ∷ ExUnits → String #

showList ∷ [ExUnits] → ShowS #

Eq ExUnits Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Methods

(==) ∷ ExUnits → ExUnits → Bool #

(/=) ∷ ExUnits → ExUnits → Bool #

NoThunks ExUnits Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

type Rep ExUnits Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

type Rep ExUnits = D1 ('MetaData "ExUnits" "Cardano.Ledger.Plutus.ExUnits" "cardano-ledger-core-1.22.0.0-inplace" 'True) (C1 ('MetaCons "WrapExUnits" 'PrefixI 'True) (S1 ('MetaSel ('Just "unWrapExUnits") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ExUnits' Natural))))

data ExUnits' a Source #

Arbitrary execution unit in which we measure the cost of scripts in terms of space in memory and execution time.

The ledger itself uses ExUnits Natural' exclusively, but the flexibility here allows the consensus layer to translate the execution units into something equivalent to 'ExUnits (Inf Natural)'. This is needed in order to provide a BoundedMeasure instance, which itself is needed for the alonzo instance of TxLimits (in consensus).

Constructors

ExUnits' 

Fields

Instances

Instances details
Functor ExUnits' Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Methods

fmap ∷ (a → b) → ExUnits' a → ExUnits' b #

(<$) ∷ a → ExUnits' b → ExUnits' a #

FromJSON a ⇒ FromJSON (ExUnits' a) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

ToJSON a ⇒ ToJSON (ExUnits' a) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

NFData a ⇒ NFData (ExUnits' a) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Methods

rnf ∷ ExUnits' a → () #

Measure a ⇒ Monoid (ExUnits' a) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Methods

mempty ∷ ExUnits' a #

mappend ∷ ExUnits' a → ExUnits' a → ExUnits' a #

mconcat ∷ [ExUnits' a] → ExUnits' a #

Measure a ⇒ Semigroup (ExUnits' a) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Methods

(<>) ∷ ExUnits' a → ExUnits' a → ExUnits' a #

sconcat ∷ NonEmpty (ExUnits' a) → ExUnits' a #

stimes ∷ Integral b ⇒ b → ExUnits' a → ExUnits' a #

Generic (ExUnits' a) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Associated Types

type Rep (ExUnits' a) 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

type Rep (ExUnits' a) = D1 ('MetaData "ExUnits'" "Cardano.Ledger.Plutus.ExUnits" "cardano-ledger-core-1.22.0.0-inplace" 'False) (C1 ('MetaCons "ExUnits'" 'PrefixI 'True) (S1 ('MetaSel ('Just "exUnitsMem'") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "exUnitsSteps'") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)))

Methods

from ∷ ExUnits' a → Rep (ExUnits' a) x #

to ∷ Rep (ExUnits' a) x → ExUnits' a #

Show a ⇒ Show (ExUnits' a) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Methods

showsPrec ∷ Int → ExUnits' a → ShowS #

show ∷ ExUnits' a → String #

showList ∷ [ExUnits' a] → ShowS #

Eq a ⇒ Eq (ExUnits' a) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Methods

(==) ∷ ExUnits' a → ExUnits' a → Bool #

(/=) ∷ ExUnits' a → ExUnits' a → Bool #

BoundedMeasure a ⇒ BoundedMeasure (ExUnits' a) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Methods

maxBound ∷ ExUnits' a Source #

Measure a ⇒ Measure (ExUnits' a) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Methods

zero ∷ ExUnits' a Source #

plus ∷ ExUnits' a → ExUnits' a → ExUnits' a Source #

min ∷ ExUnits' a → ExUnits' a → ExUnits' a Source #

max ∷ ExUnits' a → ExUnits' a → ExUnits' a Source #

NoThunks a ⇒ NoThunks (ExUnits' a) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

type Rep (ExUnits' a) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

type Rep (ExUnits' a) = D1 ('MetaData "ExUnits'" "Cardano.Ledger.Plutus.ExUnits" "cardano-ledger-core-1.22.0.0-inplace" 'False) (C1 ('MetaCons "ExUnits'" 'PrefixI 'True) (S1 ('MetaSel ('Just "exUnitsMem'") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "exUnitsSteps'") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)))

newtype OrdExUnits Source #

This is a helper type that allows us to define an Ord instance for executions units without affecting the ExUnits type. This is needed in order to derive an Ord instance` for types that need to contain an ExUnits. This is just a helper type and should not be used directly.

Constructors

OrdExUnits 

Fields

Instances

Instances details
FromJSON OrdExUnits Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

ToJSON OrdExUnits Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

DecCBOR OrdExUnits Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

EncCBOR OrdExUnits Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

ToPlutusData OrdExUnits Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ToPlutusData

NFData OrdExUnits Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Methods

rnf ∷ OrdExUnits → () #

Show OrdExUnits Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Eq OrdExUnits Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Methods

(==) ∷ OrdExUnits → OrdExUnits → Bool #

(/=) ∷ OrdExUnits → OrdExUnits → Bool #

Ord OrdExUnits Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

NoThunks OrdExUnits Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

data Prices Source #

Prices per execution unit

Instances

Instances details
FromJSON Prices Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

ToJSON Prices Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

DecCBOR Prices Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

EncCBOR Prices Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Methods

encCBOR ∷ Prices → Encoding Source #

ToPlutusData Prices Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ToPlutusData

NFData Prices Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Methods

rnf ∷ Prices → () #

Generic Prices Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Associated Types

type Rep Prices 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

type Rep Prices = D1 ('MetaData "Prices" "Cardano.Ledger.Plutus.ExUnits" "cardano-ledger-core-1.22.0.0-inplace" 'False) (C1 ('MetaCons "Prices" 'PrefixI 'True) (S1 ('MetaSel ('Just "prMem") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 NonNegativeInterval) :*: S1 ('MetaSel ('Just "prSteps") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 NonNegativeInterval)))

Methods

from ∷ Prices → Rep Prices x #

to ∷ Rep Prices x → Prices #

Show Prices Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Methods

showsPrec ∷ Int → Prices → ShowS #

show ∷ Prices → String #

showList ∷ [Prices] → ShowS #

Eq Prices Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Methods

(==) ∷ Prices → Prices → Bool #

(/=) ∷ Prices → Prices → Bool #

Ord Prices Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

Methods

compare ∷ Prices → Prices → Ordering #

(<) ∷ Prices → Prices → Bool #

(<=) ∷ Prices → Prices → Bool #

(>) ∷ Prices → Prices → Bool #

(>=) ∷ Prices → Prices → Bool #

max ∷ Prices → Prices → Prices #

min ∷ Prices → Prices → Prices #

NoThunks Prices Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

type Rep Prices Source # 
Instance details

Defined in Cardano.Ledger.Plutus.ExUnits

type Rep Prices = D1 ('MetaData "Prices" "Cardano.Ledger.Plutus.ExUnits" "cardano-ledger-core-1.22.0.0-inplace" 'False) (C1 ('MetaCons "Prices" 'PrefixI 'True) (S1 ('MetaSel ('Just "prMem") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 NonNegativeInterval) :*: S1 ('MetaSel ('Just "prSteps") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 NonNegativeInterval)))