module PlutusCore.Evaluation.Machine.MachineParameters.Default where
import PlutusPrelude
import PlutusCore.Builtin
import PlutusCore.Default
import PlutusCore.Evaluation.Machine.CostModelInterface
import PlutusCore.Evaluation.Machine.ExBudgetingDefaults
import PlutusCore.Evaluation.Machine.MachineParameters
import UntypedPlutusCore.Evaluation.Machine.Cek
import Control.DeepSeq (force)
import Control.Monad.Except
import GHC.Exts (inline)
type DefaultMachineParameters =
MachineParameters CekMachineCosts DefaultFun (CekValue DefaultUni DefaultFun ())
mkMachineParametersFor
:: MonadError CostModelApplyError m
=> [BuiltinSemanticsVariant DefaultFun]
-> CostModelParams
-> m [(BuiltinSemanticsVariant DefaultFun, DefaultMachineParameters)]
mkMachineParametersFor :: forall (m :: * -> *).
MonadError CostModelApplyError m =>
[BuiltinSemanticsVariant DefaultFun]
-> CostModelParams
-> m [(BuiltinSemanticsVariant DefaultFun,
DefaultMachineParameters)]
mkMachineParametersFor [BuiltinSemanticsVariant DefaultFun]
semVars CostModelParams
newCMP = do
[(BuiltinSemanticsVariant DefaultFun, DefaultMachineParameters)]
res <- [BuiltinSemanticsVariant DefaultFun]
-> (BuiltinSemanticsVariant DefaultFun
-> m (BuiltinSemanticsVariant DefaultFun,
DefaultMachineParameters))
-> m [(BuiltinSemanticsVariant DefaultFun,
DefaultMachineParameters)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
t a -> (a -> f b) -> f (t b)
for [BuiltinSemanticsVariant DefaultFun]
semVars ((BuiltinSemanticsVariant DefaultFun
-> m (BuiltinSemanticsVariant DefaultFun,
DefaultMachineParameters))
-> m [(BuiltinSemanticsVariant DefaultFun,
DefaultMachineParameters)])
-> (BuiltinSemanticsVariant DefaultFun
-> m (BuiltinSemanticsVariant DefaultFun,
DefaultMachineParameters))
-> m [(BuiltinSemanticsVariant DefaultFun,
DefaultMachineParameters)]
forall a b. (a -> b) -> a -> b
$ \BuiltinSemanticsVariant DefaultFun
semVar ->
(,) BuiltinSemanticsVariant DefaultFun
semVar (DefaultMachineParameters
-> (BuiltinSemanticsVariant DefaultFun, DefaultMachineParameters))
-> (CostModel CekMachineCosts BuiltinCostModel
-> DefaultMachineParameters)
-> CostModel CekMachineCosts BuiltinCostModel
-> (BuiltinSemanticsVariant DefaultFun, DefaultMachineParameters)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (BuiltinSemanticsVariant DefaultFun
-> CostModel CekMachineCosts BuiltinCostModel
-> DefaultMachineParameters)
-> BuiltinSemanticsVariant DefaultFun
-> CostModel CekMachineCosts BuiltinCostModel
-> DefaultMachineParameters
forall a. a -> a
inline BuiltinSemanticsVariant DefaultFun
-> CostModel CekMachineCosts BuiltinCostModel
-> DefaultMachineParameters
forall (uni :: * -> *) fun builtincosts val machinecosts.
(CostingPart uni fun ~ builtincosts, HasMeaningIn uni val,
ToBuiltinMeaning uni fun) =>
BuiltinSemanticsVariant fun
-> CostModel machinecosts builtincosts
-> MachineParameters machinecosts fun val
mkMachineParameters BuiltinSemanticsVariant DefaultFun
semVar (CostModel CekMachineCosts BuiltinCostModel
-> (BuiltinSemanticsVariant DefaultFun, DefaultMachineParameters))
-> m (CostModel CekMachineCosts BuiltinCostModel)
-> m (BuiltinSemanticsVariant DefaultFun, DefaultMachineParameters)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
CostModel CekMachineCosts BuiltinCostModel
-> CostModelParams
-> m (CostModel CekMachineCosts BuiltinCostModel)
forall evaluatorcosts builtincosts (m :: * -> *).
(FromJSON evaluatorcosts, FromJSON builtincosts,
ToJSON evaluatorcosts, ToJSON builtincosts,
MonadError CostModelApplyError m) =>
CostModel evaluatorcosts builtincosts
-> CostModelParams -> m (CostModel evaluatorcosts builtincosts)
applyCostModelParams (BuiltinSemanticsVariant DefaultFun
-> CostModel CekMachineCosts BuiltinCostModel
cekCostModelForVariant BuiltinSemanticsVariant DefaultFun
semVar) CostModelParams
newCMP
[(BuiltinSemanticsVariant DefaultFun, DefaultMachineParameters)]
-> m [(BuiltinSemanticsVariant DefaultFun,
DefaultMachineParameters)]
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(BuiltinSemanticsVariant DefaultFun, DefaultMachineParameters)]
-> m [(BuiltinSemanticsVariant DefaultFun,
DefaultMachineParameters)])
-> [(BuiltinSemanticsVariant DefaultFun, DefaultMachineParameters)]
-> m [(BuiltinSemanticsVariant DefaultFun,
DefaultMachineParameters)]
forall a b. (a -> b) -> a -> b
$! [(BuiltinSemanticsVariant DefaultFun, DefaultMachineParameters)]
-> [(BuiltinSemanticsVariant DefaultFun, DefaultMachineParameters)]
forall a. NFData a => a -> a
force [(BuiltinSemanticsVariant DefaultFun, DefaultMachineParameters)]
res