plutus-core-1.39.0.0: Language library for Plutus Core
Safe HaskellSafe-Inferred
LanguageHaskell2010

UntypedPlutusCore.Evaluation.Machine.Cek.StepCounter

Synopsis

Documentation

newtype StepCounter (n ∷ Nat) s Source #

A set of Word8 counters that is used in the CEK machine to count steps.

newCounter ∷ (KnownNat n, PrimMonad m) ⇒ Proxy n → m (StepCounter n (PrimState m)) Source #

Make a new StepCounter with the given number of counters.

resetCounter ∷ ∀ n m. (KnownNat n, PrimMonad m) ⇒ StepCounter n (PrimState m) → m () Source #

Reset all the counters in the given StepCounter to zero.

readCounter ∷ ∀ m n. PrimMonad m ⇒ StepCounter n (PrimState m) → Int → m Word8 Source #

Read the value of a counter.

writeCounter ∷ ∀ m n. PrimMonad m ⇒ StepCounter n (PrimState m) → IntWord8 → m () Source #

Write to a counter.

modifyCounterPrimMonad m ⇒ Int → (Word8Word8) → StepCounter n (PrimState m) → m Word8 Source #

Modify the value of a counter. Returns the modified value.

data Peano Source #

The type of natural numbers in Peano form.

Constructors

Z 
S Peano 

type family NatToPeano n where ... Source #

Equations

NatToPeano 0 = 'Z 
NatToPeano n = 'S (NatToPeano (n - 1)) 

class Applicative f ⇒ UpwardsM f n where Source #

Methods

upwardsMInt → (Int → f ()) → f () Source #

upwardsM i k means k i *> k (i + 1) *> ... *> k (i + n - 1). We use this function in order to statically unroll a loop in itraverseCounter_ through instance resolution. This makes validation benchmarks a couple of percent faster.

Instances

Instances details
Applicative f ⇒ UpwardsM f 'Z Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.StepCounter

Methods

upwardsMInt → (Int → f ()) → f () Source #

UpwardsM f n ⇒ UpwardsM f ('S n) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.StepCounter

Methods

upwardsMInt → (Int → f ()) → f () Source #

itraverseCounter_ ∷ ∀ n m. (UpwardsM m (NatToPeano n), PrimMonad m) ⇒ (IntWord8 → m ()) → StepCounter n (PrimState m) → m () Source #

Traverse the counters with an effectful function.

iforCounter_ ∷ (UpwardsM m (NatToPeano n), PrimMonad m) ⇒ StepCounter n (PrimState m) → (IntWord8 → m ()) → m () Source #

Traverse the counters with an effectful function.