{-# LANGUAGE TypeApplications #-}
module PlutusLedgerApi.V3.EvaluationContext
( EvaluationContext
, mkEvaluationContext
, CostModelParams
, assertWellFormedCostModelParams
, toMachineParameters
, CostModelApplyError (..)
) where
import PlutusLedgerApi.Common
import PlutusLedgerApi.V3.ParamName as V3
import PlutusCore.Default (BuiltinSemanticsVariant (DefaultFunSemanticsVariantC))
import Control.Monad
import Control.Monad.Writer.Strict
import Data.Int (Int64)
mkEvaluationContext :: (MonadError CostModelApplyError m, MonadWriter [CostModelApplyWarn] m)
=> [Int64]
-> m EvaluationContext
mkEvaluationContext :: forall (m :: * -> *).
(MonadError CostModelApplyError m,
MonadWriter [CostModelApplyWarn] m) =>
[Int64] -> m EvaluationContext
mkEvaluationContext =
forall k (m :: * -> *).
(Enum k, Bounded k, MonadError CostModelApplyError m,
MonadWriter [CostModelApplyWarn] m) =>
[Int64] -> m [(k, Int64)]
tagWithParamNames @V3.ParamName
([Int64] -> m [(ParamName, Int64)])
-> ([(ParamName, Int64)] -> m EvaluationContext)
-> [Int64]
-> m EvaluationContext
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> CostModelParams -> m CostModelParams
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CostModelParams -> m CostModelParams)
-> ([(ParamName, Int64)] -> CostModelParams)
-> [(ParamName, Int64)]
-> m CostModelParams
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(ParamName, Int64)] -> CostModelParams
forall p. IsParamName p => [(p, Int64)] -> CostModelParams
toCostModelParams
([(ParamName, Int64)] -> m CostModelParams)
-> (CostModelParams -> m EvaluationContext)
-> [(ParamName, Int64)]
-> m EvaluationContext
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> PlutusLedgerLanguage
-> [BuiltinSemanticsVariant DefaultFun]
-> (MajorProtocolVersion -> BuiltinSemanticsVariant DefaultFun)
-> CostModelParams
-> m EvaluationContext
forall (m :: * -> *).
MonadError CostModelApplyError m =>
PlutusLedgerLanguage
-> [BuiltinSemanticsVariant DefaultFun]
-> (MajorProtocolVersion -> BuiltinSemanticsVariant DefaultFun)
-> CostModelParams
-> m EvaluationContext
mkDynEvaluationContext
PlutusLedgerLanguage
PlutusV3
[BuiltinSemanticsVariant DefaultFun
DefaultFunSemanticsVariantC]
(BuiltinSemanticsVariant DefaultFun
-> MajorProtocolVersion -> BuiltinSemanticsVariant DefaultFun
forall a b. a -> b -> a
const BuiltinSemanticsVariant DefaultFun
DefaultFunSemanticsVariantC)