8

While declaring records for use in Plutus strict operator is used like this:

data Auction = Auction
   { aSeller   :: !PubKeyHash
   , aDeadline :: !Slot
   , aMinBid   :: !Integer
   , aCurrency :: !CurrencySymbol
   , aToken    :: !TokenName
   } deriving (Show, Generic, ToJSON, FromJSON, ToSchema)

Does this mean that Plutus Core does not use lazy evaluation?

6

This is correct. Plutus Core uses eager evaluation. You can see this in the first section of the Plutus Core Specification. I'm not sure why however I'd expect it is to allow you to accurately estimate fees and avoid infinite data structures.

This PDF contains the formal language specifications of the Plutus Core language.

0

Cardano documentation says the following:

Plutus Core is the scripting language used by Cardano to implement the EUTXO model. It is a simple, functional language similar to Haskell, and a large subset of Haskell can be used to write Plutus Core scripts.

So, if Plutus Core is a Haskell-based language it is a lazy language too – hence, script's values are only computed when they are needed. But bang operator ! is an important part of Plutus Core as well.

In your example bang patterns are used to force Plutus Core to be more strict in its evaluation (we must force evaluation of those values before evaluating them). All banged properties are eagerly needed for committing a current operation, thus, that's why we use ! ops.

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .