Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- type BuiltinCostModel = BuiltinCostModelBase CostingFun
- data BuiltinCostModelBase f = BuiltinCostModelBase {
- paramAddInteger ∷ f ModelTwoArguments
- paramSubtractInteger ∷ f ModelTwoArguments
- paramMultiplyInteger ∷ f ModelTwoArguments
- paramDivideInteger ∷ f ModelTwoArguments
- paramQuotientInteger ∷ f ModelTwoArguments
- paramRemainderInteger ∷ f ModelTwoArguments
- paramModInteger ∷ f ModelTwoArguments
- paramEqualsInteger ∷ f ModelTwoArguments
- paramLessThanInteger ∷ f ModelTwoArguments
- paramLessThanEqualsInteger ∷ f ModelTwoArguments
- paramAppendByteString ∷ f ModelTwoArguments
- paramConsByteString ∷ f ModelTwoArguments
- paramSliceByteString ∷ f ModelThreeArguments
- paramLengthOfByteString ∷ f ModelOneArgument
- paramIndexByteString ∷ f ModelTwoArguments
- paramEqualsByteString ∷ f ModelTwoArguments
- paramLessThanByteString ∷ f ModelTwoArguments
- paramLessThanEqualsByteString ∷ f ModelTwoArguments
- paramSha2_256 ∷ f ModelOneArgument
- paramSha3_256 ∷ f ModelOneArgument
- paramBlake2b_256 ∷ f ModelOneArgument
- paramVerifyEd25519Signature ∷ f ModelThreeArguments
- paramVerifyEcdsaSecp256k1Signature ∷ f ModelThreeArguments
- paramVerifySchnorrSecp256k1Signature ∷ f ModelThreeArguments
- paramAppendString ∷ f ModelTwoArguments
- paramEqualsString ∷ f ModelTwoArguments
- paramEncodeUtf8 ∷ f ModelOneArgument
- paramDecodeUtf8 ∷ f ModelOneArgument
- paramIfThenElse ∷ f ModelThreeArguments
- paramChooseUnit ∷ f ModelTwoArguments
- paramTrace ∷ f ModelTwoArguments
- paramFstPair ∷ f ModelOneArgument
- paramSndPair ∷ f ModelOneArgument
- paramChooseList ∷ f ModelThreeArguments
- paramMkCons ∷ f ModelTwoArguments
- paramHeadList ∷ f ModelOneArgument
- paramTailList ∷ f ModelOneArgument
- paramNullList ∷ f ModelOneArgument
- paramChooseData ∷ f ModelSixArguments
- paramConstrData ∷ f ModelTwoArguments
- paramMapData ∷ f ModelOneArgument
- paramListData ∷ f ModelOneArgument
- paramIData ∷ f ModelOneArgument
- paramBData ∷ f ModelOneArgument
- paramUnConstrData ∷ f ModelOneArgument
- paramUnMapData ∷ f ModelOneArgument
- paramUnListData ∷ f ModelOneArgument
- paramUnIData ∷ f ModelOneArgument
- paramUnBData ∷ f ModelOneArgument
- paramEqualsData ∷ f ModelTwoArguments
- paramMkPairData ∷ f ModelTwoArguments
- paramMkNilData ∷ f ModelOneArgument
- paramMkNilPairData ∷ f ModelOneArgument
- paramSerialiseData ∷ f ModelOneArgument
- paramBls12_381_G1_add ∷ f ModelTwoArguments
- paramBls12_381_G1_neg ∷ f ModelOneArgument
- paramBls12_381_G1_scalarMul ∷ f ModelTwoArguments
- paramBls12_381_G1_equal ∷ f ModelTwoArguments
- paramBls12_381_G1_compress ∷ f ModelOneArgument
- paramBls12_381_G1_uncompress ∷ f ModelOneArgument
- paramBls12_381_G1_hashToGroup ∷ f ModelTwoArguments
- paramBls12_381_G2_add ∷ f ModelTwoArguments
- paramBls12_381_G2_neg ∷ f ModelOneArgument
- paramBls12_381_G2_scalarMul ∷ f ModelTwoArguments
- paramBls12_381_G2_equal ∷ f ModelTwoArguments
- paramBls12_381_G2_compress ∷ f ModelOneArgument
- paramBls12_381_G2_uncompress ∷ f ModelOneArgument
- paramBls12_381_G2_hashToGroup ∷ f ModelTwoArguments
- paramBls12_381_millerLoop ∷ f ModelTwoArguments
- paramBls12_381_mulMlResult ∷ f ModelTwoArguments
- paramBls12_381_finalVerify ∷ f ModelTwoArguments
- paramKeccak_256 ∷ f ModelOneArgument
- paramBlake2b_224 ∷ f ModelOneArgument
- paramIntegerToByteString ∷ f ModelThreeArguments
- paramByteStringToInteger ∷ f ModelTwoArguments
- paramAndByteString ∷ f ModelThreeArguments
- paramOrByteString ∷ f ModelThreeArguments
- paramXorByteString ∷ f ModelThreeArguments
- paramComplementByteString ∷ f ModelOneArgument
- paramReadBit ∷ f ModelTwoArguments
- paramWriteBits ∷ f ModelThreeArguments
- paramReplicateByte ∷ f ModelTwoArguments
- paramShiftByteString ∷ f ModelTwoArguments
- paramRotateByteString ∷ f ModelTwoArguments
- paramCountSetBits ∷ f ModelOneArgument
- paramFindFirstSetBit ∷ f ModelOneArgument
- paramRipemd_160 ∷ f ModelOneArgument
- paramExpModInteger ∷ f ModelThreeArguments
- data CostingFun model = CostingFun {
- costingFunCpu ∷ model
- costingFunMemory ∷ model
- class UnimplementedCostingFun a where
- unimplementedCostingFun ∷ b → CostingFun a
- newtype Intercept = Intercept {}
- newtype Slope = Slope {}
- newtype Coefficient0 = Coefficient0 {}
- newtype Coefficient1 = Coefficient1 {}
- newtype Coefficient2 = Coefficient2 {}
- newtype Coefficient00 = Coefficient00 {}
- newtype Coefficient10 = Coefficient10 {}
- newtype Coefficient01 = Coefficient01 {}
- newtype Coefficient20 = Coefficient20 {}
- newtype Coefficient11 = Coefficient11 {}
- newtype Coefficient02 = Coefficient02 {}
- data OneVariableLinearFunction = OneVariableLinearFunction {}
- data OneVariableQuadraticFunction = OneVariableQuadraticFunction {}
- data TwoVariableLinearFunction = TwoVariableLinearFunction {}
- data TwoVariableQuadraticFunction = TwoVariableQuadraticFunction {
- twoVariableQuadraticFunctionMinimum ∷ CostingInteger
- twoVariableQuadraticFunctionC00 ∷ Coefficient00
- twoVariableQuadraticFunctionC10 ∷ Coefficient10
- twoVariableQuadraticFunctionC01 ∷ Coefficient01
- twoVariableQuadraticFunctionC20 ∷ Coefficient20
- twoVariableQuadraticFunctionC11 ∷ Coefficient11
- twoVariableQuadraticFunctionC02 ∷ Coefficient02
- data ModelSubtractedSizes = ModelSubtractedSizes {}
- data ModelConstantOrOneArgument = ModelConstantOrOneArgument {}
- data ModelConstantOrTwoArguments = ModelConstantOrTwoArguments {}
- data ModelConstantOrLinear = ModelConstantOrLinear {}
- data ModelOneArgument
- data ModelTwoArguments
- = ModelTwoArgumentsConstantCost CostingInteger
- | ModelTwoArgumentsLinearInX OneVariableLinearFunction
- | ModelTwoArgumentsLinearInY OneVariableLinearFunction
- | ModelTwoArgumentsLinearInXAndY TwoVariableLinearFunction
- | ModelTwoArgumentsAddedSizes OneVariableLinearFunction
- | ModelTwoArgumentsSubtractedSizes ModelSubtractedSizes
- | ModelTwoArgumentsMultipliedSizes OneVariableLinearFunction
- | ModelTwoArgumentsMinSize OneVariableLinearFunction
- | ModelTwoArgumentsMaxSize OneVariableLinearFunction
- | ModelTwoArgumentsLinearOnDiagonal ModelConstantOrLinear
- | ModelTwoArgumentsConstOffDiagonal ModelConstantOrOneArgument
- | ModelTwoArgumentsConstAboveDiagonal ModelConstantOrTwoArguments
- | ModelTwoArgumentsConstBelowDiagonal ModelConstantOrTwoArguments
- | ModelTwoArgumentsQuadraticInY OneVariableQuadraticFunction
- | ModelTwoArgumentsQuadraticInXAndY TwoVariableQuadraticFunction
- data ModelThreeArguments
- = ModelThreeArgumentsConstantCost CostingInteger
- | ModelThreeArgumentsLinearInX OneVariableLinearFunction
- | ModelThreeArgumentsLinearInY OneVariableLinearFunction
- | ModelThreeArgumentsLinearInZ OneVariableLinearFunction
- | ModelThreeArgumentsQuadraticInZ OneVariableQuadraticFunction
- | ModelThreeArgumentsLiteralInYOrLinearInZ OneVariableLinearFunction
- | ModelThreeArgumentsLinearInMaxYZ OneVariableLinearFunction
- | ModelThreeArgumentsLinearInYAndZ TwoVariableLinearFunction
- data ModelFourArguments = ModelFourArgumentsConstantCost CostingInteger
- data ModelFiveArguments = ModelFiveArgumentsConstantCost CostingInteger
- data ModelSixArguments = ModelSixArgumentsConstantCost CostingInteger
- runCostingFunOneArgument ∷ ExMemoryUsage a1 ⇒ CostingFun ModelOneArgument → a1 → ExBudgetStream
- runCostingFunTwoArguments ∷ (ExMemoryUsage a1, ExMemoryUsage a2) ⇒ CostingFun ModelTwoArguments → a1 → a2 → ExBudgetStream
- runCostingFunThreeArguments ∷ (ExMemoryUsage a1, ExMemoryUsage a2, ExMemoryUsage a3) ⇒ CostingFun ModelThreeArguments → a1 → a2 → a3 → ExBudgetStream
- runCostingFunFourArguments ∷ (ExMemoryUsage a1, ExMemoryUsage a2, ExMemoryUsage a3, ExMemoryUsage a4) ⇒ CostingFun ModelFourArguments → a1 → a2 → a3 → a4 → ExBudgetStream
- runCostingFunFiveArguments ∷ (ExMemoryUsage a1, ExMemoryUsage a2, ExMemoryUsage a3, ExMemoryUsage a4, ExMemoryUsage a5) ⇒ CostingFun ModelFiveArguments → a1 → a2 → a3 → a4 → a5 → ExBudgetStream
- runCostingFunSixArguments ∷ (ExMemoryUsage a1, ExMemoryUsage a2, ExMemoryUsage a3, ExMemoryUsage a4, ExMemoryUsage a5, ExMemoryUsage a6) ⇒ CostingFun ModelSixArguments → a1 → a2 → a3 → a4 → a5 → a6 → ExBudgetStream
- class Eq a ⇒ Hashable a
- newtype MCostingFun a = MCostingFun (Maybe (CostingFun a))
Documentation
data BuiltinCostModelBase f Source #
The main model which contains all data required to predict the cost of
builtin functions. See md
for how this is
generated. Calibrated for the CEK machine.
Instances
data CostingFun model Source #
A type of costing functions parametric over a model type. In practice the we have one model type `ModelNArguments` for every N, where N is the arity of the builtin whose costs we want to model. Each model type has a number of constructors defining different "shapes" of N-parameter functions which calculate a cost given the sizes of the builtin's arguments.
CostingFun | |
|
Instances
class UnimplementedCostingFun a where Source #
In the initial stages of implementing a new builtin it is necessary to
provide a temporary costing function which is used until the builtin has been
properly costed: `see CostModelGeneration.md`. Each `ModelNArguments` type
defines an instance of this class where unimplementedCostingFun
is a
constant costing function which returns a very high cost for all inputs.
This prevents new functions from being used in situations where costs are
important until a sensible costing function has been implemented.
unimplementedCostingFun ∷ b → CostingFun a Source #
Instances
A wrapped CostingInteger
that is supposed to be used as an intercept.
Instances
FromJSON Intercept Source # | |
Defined in PlutusCore.Evaluation.Machine.CostingFun.JSON parseJSON ∷ Value → Parser Intercept parseJSONList ∷ Value → Parser [Intercept] | |
ToJSON Intercept Source # | |
Defined in PlutusCore.Evaluation.Machine.CostingFun.JSON toEncoding ∷ Intercept → Encoding toJSONList ∷ [Intercept] → Value toEncodingList ∷ [Intercept] → Encoding | |
Generic Intercept Source # | |
Num Intercept Source # | |
Show Intercept Source # | |
NFData Intercept Source # | |
Eq Intercept Source # | |
Lift Intercept Source # | |
type Rep Intercept Source # | |
Defined in PlutusCore.Evaluation.Machine.CostingFun.Core type Rep Intercept = D1 ('MetaData "Intercept" "PlutusCore.Evaluation.Machine.CostingFun.Core" "plutus-core-1.39.0.0-inplace" 'True) (C1 ('MetaCons "Intercept" 'PrefixI 'True) (S1 ('MetaSel ('Just "unIntercept") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CostingInteger))) |
A wrapped CostingInteger
that is supposed to be used as a slope.
Instances
FromJSON Slope Source # | |
ToJSON Slope Source # | |
Generic Slope Source # | |
Num Slope Source # | |
Show Slope Source # | |
NFData Slope Source # | |
Eq Slope Source # | |
Lift Slope Source # | |
type Rep Slope Source # | |
Defined in PlutusCore.Evaluation.Machine.CostingFun.Core type Rep Slope = D1 ('MetaData "Slope" "PlutusCore.Evaluation.Machine.CostingFun.Core" "plutus-core-1.39.0.0-inplace" 'True) (C1 ('MetaCons "Slope" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSlope") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CostingInteger))) |
newtype Coefficient0 Source #
A wrapped CostingInteger
that is supposed to be used as the degree 0
coefficient of a polynomial.
Instances
newtype Coefficient1 Source #
A wrapped CostingInteger
that is supposed to be used as the degree 1
coefficient of a polynomial.
Instances
newtype Coefficient2 Source #
A wrapped CostingInteger
that is supposed to be used as the degree 2
coefficient of a polynomial.
Instances
newtype Coefficient00 Source #
A wrapped CostingInteger
that is supposed to be used as the degree (0,0)
coefficient of a two-variable polynomial.
Instances
newtype Coefficient10 Source #
A wrapped CostingInteger
that is supposed to be used as the degree (1,0)
coefficient of a two-variable polynomial.
Instances
newtype Coefficient01 Source #
A wrapped CostingInteger
that is supposed to be used as the degree (0,1)
coefficient of a two-variable polynomial.
Instances
newtype Coefficient20 Source #
A wrapped CostingInteger
that is supposed to be used as the degree (2,0)
coefficient of a two-variable polynomial.
Instances
newtype Coefficient11 Source #
A wrapped CostingInteger
that is supposed to be used as the degree (1,1)
coefficient of a two-variable polynomial.
Instances
newtype Coefficient02 Source #
A wrapped CostingInteger
that is supposed to be used as the degree (0,2)
coefficient of a two-variable polynomial.
Instances
data OneVariableLinearFunction Source #
s * x + I
Instances
data OneVariableQuadraticFunction Source #
c0 + c1*x + c2*x^2
Instances
data TwoVariableLinearFunction Source #
s1 * x + s2 * y + I
Instances
data TwoVariableQuadraticFunction Source #
c00 + c10*x + c01*y + c20*x^2 + c11*c*y + c02*y^2
Instances
data ModelSubtractedSizes Source #
s * (x - y) + I
Instances
data ModelConstantOrOneArgument Source #
if p then f(x) else c; p depends on usage
Instances
data ModelConstantOrTwoArguments Source #
if p then f(x,y) else c; p depends on usage
Instances
data ModelConstantOrLinear Source #
NB: this is subsumed by ModelConstantOrOneArgument, but we have to keep it for the time being. See Note [Backward compatibility for costing functions]. | if p then s*x else c; p depends on usage
Instances
data ModelOneArgument Source #
Instances
data ModelTwoArguments Source #
Instances
data ModelThreeArguments Source #
Instances
data ModelFourArguments Source #
Instances
data ModelFiveArguments Source #
Instances
data ModelSixArguments Source #
Instances
runCostingFunOneArgument ∷ ExMemoryUsage a1 ⇒ CostingFun ModelOneArgument → a1 → ExBudgetStream Source #
runCostingFunTwoArguments ∷ (ExMemoryUsage a1, ExMemoryUsage a2) ⇒ CostingFun ModelTwoArguments → a1 → a2 → ExBudgetStream Source #
runCostingFunThreeArguments ∷ (ExMemoryUsage a1, ExMemoryUsage a2, ExMemoryUsage a3) ⇒ CostingFun ModelThreeArguments → a1 → a2 → a3 → ExBudgetStream Source #
runCostingFunFourArguments ∷ (ExMemoryUsage a1, ExMemoryUsage a2, ExMemoryUsage a3, ExMemoryUsage a4) ⇒ CostingFun ModelFourArguments → a1 → a2 → a3 → a4 → ExBudgetStream Source #
runCostingFunFiveArguments ∷ (ExMemoryUsage a1, ExMemoryUsage a2, ExMemoryUsage a3, ExMemoryUsage a4, ExMemoryUsage a5) ⇒ CostingFun ModelFiveArguments → a1 → a2 → a3 → a4 → a5 → ExBudgetStream Source #
runCostingFunSixArguments ∷ (ExMemoryUsage a1, ExMemoryUsage a2, ExMemoryUsage a3, ExMemoryUsage a4, ExMemoryUsage a5, ExMemoryUsage a6) ⇒ CostingFun ModelSixArguments → a1 → a2 → a3 → a4 → a5 → a6 → ExBudgetStream Source #
class Eq a ⇒ Hashable a Source #
The class of types that can be converted to a hash value.
Minimal implementation: hashWithSalt
.
Hashable
is intended exclusively for use in in-memory data structures.
.
Hashable
does not have a fixed standard.
This allows it to improve over time.
.
Because it does not have a fixed standard, different computers or computers on different versions of the code will observe different hash values.
As such, Hashable
is not recommended for use other than in-memory datastructures.
Specifically, Hashable
is not intended for network use or in applications which persist hashed values.
For stable hashing use named hashes: sha256, crc32, xxhash etc.
If you are looking for Hashable
instance in time
package,
check time-compat
Instances
newtype MCostingFun a Source #
Same as CostingFun
but maybe missing.
We could use 'Compose Maybe CostinFun' instead but we would then need an orphan ToJSON instance.
MCostingFun (Maybe (CostingFun a)) |