Skip to content

Commit

Permalink
chore: remove extra braces and pragmas, add HasCallStack
Browse files Browse the repository at this point in the history
  • Loading branch information
Unisay committed Dec 16, 2024
1 parent 04e4ecf commit 19d137e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
module PlutusLedgerApi.Test.Common.EvaluationContext
( MCostModel
, MCekMachineCosts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@ import UntypedPlutusCore.Evaluation.Machine.Cek.CekMachineCosts
import Data.Int (Int64)
import Data.Map qualified as Map
import Data.Maybe
import GHC.Stack (HasCallStack)

-- | Example values of costs for @PlutusV3@, in expected ledger order.
-- Suitable to be used in testing.
costModelParamsForTesting :: [(V3.ParamName, Int64)]
costModelParamsForTesting :: HasCallStack => [(V3.ParamName, Int64)]
costModelParamsForTesting = Map.toList $ fromJust $
Common.extractCostModelParamsLedgerOrder mCostModel

-- | The PlutusV3 "cost model" is constructed by the v4 "cost model", by clearing v4 introductions.
mCostModel :: MCostModel
mCostModel =
-- nothing to clear because v4 does not exist (yet).
(toMCostModel defaultCekCostModelForTesting) & builtinCostModel %~ clearBuiltinCostModel'
toMCostModel defaultCekCostModelForTesting & builtinCostModel %~ clearBuiltinCostModel'

{- | Assign to `mempty` those CEK constructs that @PlutusV3@ introduces (indirectly by introducing
a ledger language version with those CEK constructs).
Expand Down Expand Up @@ -84,6 +85,9 @@ clearBuiltinCostModel r = r
, paramFindFirstSetBit = mempty
, paramRipemd_160 = mempty
, paramExpModInteger = mempty
, paramLengthArray = mempty
, paramListToArray = mempty
, paramIndexArray = mempty
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@ import UntypedPlutusCore.Evaluation.Machine.Cek.CekMachineCosts
import Data.Int (Int64)
import Data.Map qualified as Map
import Data.Maybe
import GHC.Stack (HasCallStack)

-- | Example values of costs for @PlutusV3@, in expected ledger order.
-- Suitable to be used in testing.
costModelParamsForTesting :: [(V3.ParamName, Int64)]
costModelParamsForTesting :: HasCallStack => [(V3.ParamName, Int64)]
costModelParamsForTesting = Map.toList $ fromJust $
Common.extractCostModelParamsLedgerOrder mCostModel

-- | The PlutusV3 "cost model" is constructed by the v4 "cost model", by clearing v4 introductions.
mCostModel :: MCostModel
mCostModel =
-- nothing to clear because v4 does not exist (yet).
(toMCostModel defaultCekCostModelForTesting) & builtinCostModel %~ clearBuiltinCostModel'
toMCostModel defaultCekCostModelForTesting & builtinCostModel %~ clearBuiltinCostModel'

{- | Assign to `mempty` those CEK constructs that @PlutusV3@ introduces (indirectly by introducing
a ledger language version with those CEK constructs).
Expand Down Expand Up @@ -85,6 +86,9 @@ clearBuiltinCostModel r = r
, paramFindFirstSetBit = mempty
, paramRipemd_160 = mempty
, paramExpModInteger = mempty
, paramLengthArray = mempty
, paramListToArray = mempty
, paramIndexArray = mempty
}


Expand Down

0 comments on commit 19d137e

Please sign in to comment.