{-# LANGUAGE ConstraintKinds      #-}
{-# LANGUAGE DataKinds            #-}
{-# LANGUAGE DeriveAnyClass       #-}
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE OverloadedStrings    #-}
{-# LANGUAGE StrictData           #-}
{-# LANGUAGE TypeApplications     #-}
{-# LANGUAGE TypeFamilies         #-}
{-# LANGUAGE UndecidableInstances #-}

{-# OPTIONS_GHC -O0           #-}

module PlutusCore.Evaluation.Machine.BuiltinCostModel
    ( BuiltinCostModel
    , BuiltinCostModelBase(..)
    , CostingFun(..)
    , ModelAddedSizes(..)
    , ModelSubtractedSizes(..)
    , ModelConstantOrLinear(..)
    , ModelConstantOrTwoArguments(..)
    , ModelLinearSize(..)
    , ModelMultipliedSizes(..)
    , ModelMinSize(..)
    , ModelMaxSize(..)
    , ModelOneArgument(..)
    , ModelTwoArguments(..)
    , ModelThreeArguments(..)
    , ModelFourArguments(..)
    , ModelFiveArguments(..)
    , ModelSixArguments(..)
    , runCostingFunOneArgument
    , runCostingFunTwoArguments
    , runCostingFunThreeArguments
    , runCostingFunFourArguments
    , runCostingFunFiveArguments
    , runCostingFunSixArguments
    , Hashable
    )
where

import PlutusPrelude hiding (toList)

import PlutusCore.Evaluation.Machine.ExBudget
import PlutusCore.Evaluation.Machine.ExMemory

import Barbies
import Data.Aeson
import Data.Default.Class
import Data.Hashable
import Data.Kind qualified as Kind
import Deriving.Aeson
import Language.Haskell.TH.Syntax hiding (Name, newName)

type BuiltinCostModel = BuiltinCostModelBase CostingFun

-- See  Note [Budgeting units] in ExBudgeting.hs

-- If the types here change there may be difficulties compiling this file
-- because it doesn't match builtinCostModel.json (which is parsed during
-- compilation).  In that case, manually change the JSON to match or do what it
-- says in Note [Modifying the cost model] in ExBudgetingDefaults.hs.

-- | The main model which contains all data required to predict the cost of
-- builtin functions. See Note [Creation of the Cost Model] for how this is
-- generated. Calibrated for the CEK machine.

-- See Note [Modifying the cost model] in ExBudgetingDefaults.hs for an
-- explanation of how to regenerate the cost model file when this is changed.


{- | Many of the builtins have simple costs in for certain combinations of
   arguments but more complicated costs for other combinations: for example,
   equalsByteString will return imemdiately if the arguments have different
   lengths, and divideInteger a b will return immediately if a<b.  This type
   allows us to say exactly where the cost model applies (for a small selection
   of common situations) and only run the full costing function if necessary,
   returning a small cost (currently zero) otherwise. This is also helpful
   because we can't fit a sensible model to something like divideInteger, where
   costs really are zero above the diagonal but very complicated below it).
-}
data Support
    = Everywhere
    | OnDiagonal
    | BelowOrOnDiagonal
    | AboveOrOnDiagonal
    deriving (Int -> Support -> ShowS
[Support] -> ShowS
Support -> String
(Int -> Support -> ShowS)
-> (Support -> String) -> ([Support] -> ShowS) -> Show Support
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Support] -> ShowS
$cshowList :: [Support] -> ShowS
show :: Support -> String
$cshow :: Support -> String
showsPrec :: Int -> Support -> ShowS
$cshowsPrec :: Int -> Support -> ShowS
Show, Support -> Support -> Bool
(Support -> Support -> Bool)
-> (Support -> Support -> Bool) -> Eq Support
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Support -> Support -> Bool
$c/= :: Support -> Support -> Bool
== :: Support -> Support -> Bool
$c== :: Support -> Support -> Bool
Eq, (forall x. Support -> Rep Support x)
-> (forall x. Rep Support x -> Support) -> Generic Support
forall x. Rep Support x -> Support
forall x. Support -> Rep Support x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Support x -> Support
$cfrom :: forall x. Support -> Rep Support x
Generic, Support -> Q Exp
Support -> Q (TExp Support)
(Support -> Q Exp) -> (Support -> Q (TExp Support)) -> Lift Support
forall t. (t -> Q Exp) -> (t -> Q (TExp t)) -> Lift t
liftTyped :: Support -> Q (TExp Support)
$cliftTyped :: Support -> Q (TExp Support)
lift :: Support -> Q Exp
$clift :: Support -> Q Exp
Lift, Support -> ()
(Support -> ()) -> NFData Support
forall a. (a -> ()) -> NFData a
rnf :: Support -> ()
$crnf :: Support -> ()
NFData)

data BuiltinCostModelBase f =
    BuiltinCostModelBase
    {
      -- Integers
      BuiltinCostModelBase f -> f ModelTwoArguments
paramAddInteger               :: f ModelTwoArguments
    , BuiltinCostModelBase f -> f ModelTwoArguments
paramSubtractInteger          :: f ModelTwoArguments
    , BuiltinCostModelBase f -> f ModelTwoArguments
paramMultiplyInteger          :: f ModelTwoArguments
    , BuiltinCostModelBase f -> f ModelTwoArguments
paramDivideInteger            :: f ModelTwoArguments
    , BuiltinCostModelBase f -> f ModelTwoArguments
paramQuotientInteger          :: f ModelTwoArguments
    , BuiltinCostModelBase f -> f ModelTwoArguments
paramRemainderInteger         :: f ModelTwoArguments
    , BuiltinCostModelBase f -> f ModelTwoArguments
paramModInteger               :: f ModelTwoArguments
    , BuiltinCostModelBase f -> f ModelTwoArguments
paramEqualsInteger            :: f ModelTwoArguments
    , BuiltinCostModelBase f -> f ModelTwoArguments
paramLessThanInteger          :: f ModelTwoArguments
    , BuiltinCostModelBase f -> f ModelTwoArguments
paramLessThanEqualsInteger    :: f ModelTwoArguments
    -- Bytestrings
    , BuiltinCostModelBase f -> f ModelTwoArguments
paramAppendByteString         :: f ModelTwoArguments
    , BuiltinCostModelBase f -> f ModelTwoArguments
paramConsByteString           :: f ModelTwoArguments
    , BuiltinCostModelBase f -> f ModelThreeArguments
paramSliceByteString          :: f ModelThreeArguments
    , BuiltinCostModelBase f -> f ModelOneArgument
paramLengthOfByteString       :: f ModelOneArgument
    , BuiltinCostModelBase f -> f ModelTwoArguments
paramIndexByteString          :: f ModelTwoArguments
    , BuiltinCostModelBase f -> f ModelTwoArguments
paramEqualsByteString         :: f ModelTwoArguments
    , BuiltinCostModelBase f -> f ModelTwoArguments
paramLessThanByteString       :: f ModelTwoArguments
    , BuiltinCostModelBase f -> f ModelTwoArguments
paramLessThanEqualsByteString :: f ModelTwoArguments
    -- Cryptography and hashes
    , BuiltinCostModelBase f -> f ModelOneArgument
paramSha2_256                 :: f ModelOneArgument
    , BuiltinCostModelBase f -> f ModelOneArgument
paramSha3_256                 :: f ModelOneArgument
    , BuiltinCostModelBase f -> f ModelOneArgument
paramBlake2b                  :: f ModelOneArgument
       -- ^ This should really be paramBlake2b_256, but changing it might be
       -- problematic because then the names of the cost model parameters used
       -- by the ledger would change as well.
    , BuiltinCostModelBase f -> f ModelThreeArguments
paramVerifySignature          :: f ModelThreeArguments
    -- Strings
    , BuiltinCostModelBase f -> f ModelTwoArguments
paramAppendString             :: f ModelTwoArguments
    , BuiltinCostModelBase f -> f ModelTwoArguments
paramEqualsString             :: f ModelTwoArguments
    , BuiltinCostModelBase f -> f ModelOneArgument
paramEncodeUtf8               :: f ModelOneArgument
    , BuiltinCostModelBase f -> f ModelOneArgument
paramDecodeUtf8               :: f ModelOneArgument
    -- Bool
    , BuiltinCostModelBase f -> f ModelThreeArguments
paramIfThenElse               :: f ModelThreeArguments
    -- Unit
    , BuiltinCostModelBase f -> f ModelTwoArguments
paramChooseUnit               :: f ModelTwoArguments
    -- Tracing
    , BuiltinCostModelBase f -> f ModelTwoArguments
paramTrace                    :: f ModelTwoArguments
    -- Pairs
    , BuiltinCostModelBase f -> f ModelOneArgument
paramFstPair                  :: f ModelOneArgument
    , BuiltinCostModelBase f -> f ModelOneArgument
paramSndPair                  :: f ModelOneArgument
    -- Lists
    , BuiltinCostModelBase f -> f ModelThreeArguments
paramChooseList               :: f ModelThreeArguments
    , BuiltinCostModelBase f -> f ModelTwoArguments
paramMkCons                   :: f ModelTwoArguments
    , BuiltinCostModelBase f -> f ModelOneArgument
paramHeadList                 :: f ModelOneArgument
    , BuiltinCostModelBase f -> f ModelOneArgument
paramTailList                 :: f ModelOneArgument
    , BuiltinCostModelBase f -> f ModelOneArgument
paramNullList                 :: f ModelOneArgument
    -- Data
    , BuiltinCostModelBase f -> f ModelSixArguments
paramChooseData               :: f ModelSixArguments
    , BuiltinCostModelBase f -> f ModelTwoArguments
paramConstrData               :: f ModelTwoArguments
    , BuiltinCostModelBase f -> f ModelOneArgument
paramMapData                  :: f ModelOneArgument
    , BuiltinCostModelBase f -> f ModelOneArgument
paramListData                 :: f ModelOneArgument
    , BuiltinCostModelBase f -> f ModelOneArgument
paramIData                    :: f ModelOneArgument
    , BuiltinCostModelBase f -> f ModelOneArgument
paramBData                    :: f ModelOneArgument
    , BuiltinCostModelBase f -> f ModelOneArgument
paramUnConstrData             :: f ModelOneArgument
    , BuiltinCostModelBase f -> f ModelOneArgument
paramUnMapData                :: f ModelOneArgument
    , BuiltinCostModelBase f -> f ModelOneArgument
paramUnListData               :: f ModelOneArgument
    , BuiltinCostModelBase f -> f ModelOneArgument
paramUnIData                  :: f ModelOneArgument
    , BuiltinCostModelBase f -> f ModelOneArgument
paramUnBData                  :: f ModelOneArgument
    , BuiltinCostModelBase f -> f ModelTwoArguments
paramEqualsData               :: f ModelTwoArguments
    -- Misc constructors
    , BuiltinCostModelBase f -> f ModelTwoArguments
paramMkPairData               :: f ModelTwoArguments
    , BuiltinCostModelBase f -> f ModelOneArgument
paramMkNilData                :: f ModelOneArgument
    , BuiltinCostModelBase f -> f ModelOneArgument
paramMkNilPairData            :: f ModelOneArgument
    }
    deriving ((forall x.
 BuiltinCostModelBase f -> Rep (BuiltinCostModelBase f) x)
-> (forall x.
    Rep (BuiltinCostModelBase f) x -> BuiltinCostModelBase f)
-> Generic (BuiltinCostModelBase f)
forall x. Rep (BuiltinCostModelBase f) x -> BuiltinCostModelBase f
forall x. BuiltinCostModelBase f -> Rep (BuiltinCostModelBase f) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (f :: * -> *) x.
Rep (BuiltinCostModelBase f) x -> BuiltinCostModelBase f
forall (f :: * -> *) x.
BuiltinCostModelBase f -> Rep (BuiltinCostModelBase f) x
$cto :: forall (f :: * -> *) x.
Rep (BuiltinCostModelBase f) x -> BuiltinCostModelBase f
$cfrom :: forall (f :: * -> *) x.
BuiltinCostModelBase f -> Rep (BuiltinCostModelBase f) x
Generic, (forall (f :: * -> *) (g :: * -> *).
 (forall a. f a -> g a)
 -> BuiltinCostModelBase f -> BuiltinCostModelBase g)
-> FunctorB BuiltinCostModelBase
forall k (b :: (k -> *) -> *).
(forall (f :: k -> *) (g :: k -> *).
 (forall (a :: k). f a -> g a) -> b f -> b g)
-> FunctorB b
forall (f :: * -> *) (g :: * -> *).
(forall a. f a -> g a)
-> BuiltinCostModelBase f -> BuiltinCostModelBase g
bmap :: (forall a. f a -> g a)
-> BuiltinCostModelBase f -> BuiltinCostModelBase g
$cbmap :: forall (f :: * -> *) (g :: * -> *).
(forall a. f a -> g a)
-> BuiltinCostModelBase f -> BuiltinCostModelBase g
FunctorB, FunctorB BuiltinCostModelBase
FunctorB BuiltinCostModelBase
-> (forall (e :: * -> *) (f :: * -> *) (g :: * -> *).
    Applicative e =>
    (forall a. f a -> e (g a))
    -> BuiltinCostModelBase f -> e (BuiltinCostModelBase g))
-> TraversableB BuiltinCostModelBase
forall k (b :: (k -> *) -> *).
FunctorB b
-> (forall (e :: * -> *) (f :: k -> *) (g :: k -> *).
    Applicative e =>
    (forall (a :: k). f a -> e (g a)) -> b f -> e (b g))
-> TraversableB b
forall (e :: * -> *) (f :: * -> *) (g :: * -> *).
Applicative e =>
(forall a. f a -> e (g a))
-> BuiltinCostModelBase f -> e (BuiltinCostModelBase g)
btraverse :: (forall a. f a -> e (g a))
-> BuiltinCostModelBase f -> e (BuiltinCostModelBase g)
$cbtraverse :: forall (e :: * -> *) (f :: * -> *) (g :: * -> *).
Applicative e =>
(forall a. f a -> e (g a))
-> BuiltinCostModelBase f -> e (BuiltinCostModelBase g)
$cp1TraversableB :: FunctorB BuiltinCostModelBase
TraversableB, FunctorB BuiltinCostModelBase
FunctorB BuiltinCostModelBase
-> (forall (c :: * -> Constraint) (f :: * -> *).
    AllB c BuiltinCostModelBase =>
    BuiltinCostModelBase f
    -> BuiltinCostModelBase (Product (Dict c) f))
-> ConstraintsB BuiltinCostModelBase
forall k (b :: (k -> *) -> *).
FunctorB b
-> (forall (c :: k -> Constraint) (f :: k -> *).
    AllB c b =>
    b f -> b (Product (Dict c) f))
-> ConstraintsB b
forall (c :: * -> Constraint) (f :: * -> *).
AllB c BuiltinCostModelBase =>
BuiltinCostModelBase f -> BuiltinCostModelBase (Product (Dict c) f)
baddDicts :: BuiltinCostModelBase f -> BuiltinCostModelBase (Product (Dict c) f)
$cbaddDicts :: forall (c :: * -> Constraint) (f :: * -> *).
AllB c BuiltinCostModelBase =>
BuiltinCostModelBase f -> BuiltinCostModelBase (Product (Dict c) f)
$cp1ConstraintsB :: FunctorB BuiltinCostModelBase
ConstraintsB)

deriving via CustomJSON '[FieldLabelModifier (StripPrefix "param", LowerIntialCharacter)]
             (BuiltinCostModelBase CostingFun) instance ToJSON (BuiltinCostModelBase CostingFun)
deriving via CustomJSON '[FieldLabelModifier (StripPrefix "param", LowerIntialCharacter)]
             (BuiltinCostModelBase CostingFun) instance FromJSON (BuiltinCostModelBase CostingFun)


-- Needed to help derive various instances for BuiltinCostModelBase
type AllArgumentModels (constraint :: Kind.Type -> Kind.Constraint) f =
    ( constraint (f ModelOneArgument)
    , constraint (f ModelTwoArguments)
    , constraint (f ModelThreeArguments)
    , constraint (f ModelFourArguments)
    , constraint (f ModelFiveArguments)
    , constraint (f ModelSixArguments))

-- HLS doesn't like the AllBF from Barbies.
deriving instance AllArgumentModels NFData  f => NFData  (BuiltinCostModelBase f)
deriving instance AllArgumentModels Default f => Default (BuiltinCostModelBase f)
deriving instance AllArgumentModels Lift    f => Lift    (BuiltinCostModelBase f)
deriving instance AllArgumentModels Show    f => Show    (BuiltinCostModelBase f)
deriving instance AllArgumentModels Eq      f => Eq      (BuiltinCostModelBase f)

-- TODO there's probably a nice way to abstract over the number of arguments here. Feel free to implement it.

data CostingFun model = CostingFun
    { CostingFun model -> model
costingFunCpu    :: model
    , CostingFun model -> model
costingFunMemory :: model
    }
    deriving (Int -> CostingFun model -> ShowS
[CostingFun model] -> ShowS
CostingFun model -> String
(Int -> CostingFun model -> ShowS)
-> (CostingFun model -> String)
-> ([CostingFun model] -> ShowS)
-> Show (CostingFun model)
forall model. Show model => Int -> CostingFun model -> ShowS
forall model. Show model => [CostingFun model] -> ShowS
forall model. Show model => CostingFun model -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CostingFun model] -> ShowS
$cshowList :: forall model. Show model => [CostingFun model] -> ShowS
show :: CostingFun model -> String
$cshow :: forall model. Show model => CostingFun model -> String
showsPrec :: Int -> CostingFun model -> ShowS
$cshowsPrec :: forall model. Show model => Int -> CostingFun model -> ShowS
Show, CostingFun model -> CostingFun model -> Bool
(CostingFun model -> CostingFun model -> Bool)
-> (CostingFun model -> CostingFun model -> Bool)
-> Eq (CostingFun model)
forall model.
Eq model =>
CostingFun model -> CostingFun model -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CostingFun model -> CostingFun model -> Bool
$c/= :: forall model.
Eq model =>
CostingFun model -> CostingFun model -> Bool
== :: CostingFun model -> CostingFun model -> Bool
$c== :: forall model.
Eq model =>
CostingFun model -> CostingFun model -> Bool
Eq, (forall x. CostingFun model -> Rep (CostingFun model) x)
-> (forall x. Rep (CostingFun model) x -> CostingFun model)
-> Generic (CostingFun model)
forall x. Rep (CostingFun model) x -> CostingFun model
forall x. CostingFun model -> Rep (CostingFun model) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall model x. Rep (CostingFun model) x -> CostingFun model
forall model x. CostingFun model -> Rep (CostingFun model) x
$cto :: forall model x. Rep (CostingFun model) x -> CostingFun model
$cfrom :: forall model x. CostingFun model -> Rep (CostingFun model) x
Generic, CostingFun model -> Q Exp
CostingFun model -> Q (TExp (CostingFun model))
(CostingFun model -> Q Exp)
-> (CostingFun model -> Q (TExp (CostingFun model)))
-> Lift (CostingFun model)
forall model. Lift model => CostingFun model -> Q Exp
forall model.
Lift model =>
CostingFun model -> Q (TExp (CostingFun model))
forall t. (t -> Q Exp) -> (t -> Q (TExp t)) -> Lift t
liftTyped :: CostingFun model -> Q (TExp (CostingFun model))
$cliftTyped :: forall model.
Lift model =>
CostingFun model -> Q (TExp (CostingFun model))
lift :: CostingFun model -> Q Exp
$clift :: forall model. Lift model => CostingFun model -> Q Exp
Lift, CostingFun model
CostingFun model -> Default (CostingFun model)
forall a. a -> Default a
forall model. Default model => CostingFun model
def :: CostingFun model
$cdef :: forall model. Default model => CostingFun model
Default, CostingFun model -> ()
(CostingFun model -> ()) -> NFData (CostingFun model)
forall model. NFData model => CostingFun model -> ()
forall a. (a -> ()) -> NFData a
rnf :: CostingFun model -> ()
$crnf :: forall model. NFData model => CostingFun model -> ()
NFData)
    deriving (Value -> Parser [CostingFun model]
Value -> Parser (CostingFun model)
(Value -> Parser (CostingFun model))
-> (Value -> Parser [CostingFun model])
-> FromJSON (CostingFun model)
forall model. FromJSON model => Value -> Parser [CostingFun model]
forall model. FromJSON model => Value -> Parser (CostingFun model)
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [CostingFun model]
$cparseJSONList :: forall model. FromJSON model => Value -> Parser [CostingFun model]
parseJSON :: Value -> Parser (CostingFun model)
$cparseJSON :: forall model. FromJSON model => Value -> Parser (CostingFun model)
FromJSON, [CostingFun model] -> Encoding
[CostingFun model] -> Value
CostingFun model -> Encoding
CostingFun model -> Value
(CostingFun model -> Value)
-> (CostingFun model -> Encoding)
-> ([CostingFun model] -> Value)
-> ([CostingFun model] -> Encoding)
-> ToJSON (CostingFun model)
forall model. ToJSON model => [CostingFun model] -> Encoding
forall model. ToJSON model => [CostingFun model] -> Value
forall model. ToJSON model => CostingFun model -> Encoding
forall model. ToJSON model => CostingFun model -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [CostingFun model] -> Encoding
$ctoEncodingList :: forall model. ToJSON model => [CostingFun model] -> Encoding
toJSONList :: [CostingFun model] -> Value
$ctoJSONList :: forall model. ToJSON model => [CostingFun model] -> Value
toEncoding :: CostingFun model -> Encoding
$ctoEncoding :: forall model. ToJSON model => CostingFun model -> Encoding
toJSON :: CostingFun model -> Value
$ctoJSON :: forall model. ToJSON model => CostingFun model -> Value
ToJSON) via CustomJSON
        '[FieldLabelModifier (StripPrefix "costingFun", CamelToSnake)] (CostingFun model)


---------------- One-argument costing functions ----------------

data ModelOneArgument =
    ModelOneArgumentConstantCost CostingInteger
    | ModelOneArgumentLinearCost ModelLinearSize
    deriving (Int -> ModelOneArgument -> ShowS
[ModelOneArgument] -> ShowS
ModelOneArgument -> String
(Int -> ModelOneArgument -> ShowS)
-> (ModelOneArgument -> String)
-> ([ModelOneArgument] -> ShowS)
-> Show ModelOneArgument
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModelOneArgument] -> ShowS
$cshowList :: [ModelOneArgument] -> ShowS
show :: ModelOneArgument -> String
$cshow :: ModelOneArgument -> String
showsPrec :: Int -> ModelOneArgument -> ShowS
$cshowsPrec :: Int -> ModelOneArgument -> ShowS
Show, ModelOneArgument -> ModelOneArgument -> Bool
(ModelOneArgument -> ModelOneArgument -> Bool)
-> (ModelOneArgument -> ModelOneArgument -> Bool)
-> Eq ModelOneArgument
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModelOneArgument -> ModelOneArgument -> Bool
$c/= :: ModelOneArgument -> ModelOneArgument -> Bool
== :: ModelOneArgument -> ModelOneArgument -> Bool
$c== :: ModelOneArgument -> ModelOneArgument -> Bool
Eq, (forall x. ModelOneArgument -> Rep ModelOneArgument x)
-> (forall x. Rep ModelOneArgument x -> ModelOneArgument)
-> Generic ModelOneArgument
forall x. Rep ModelOneArgument x -> ModelOneArgument
forall x. ModelOneArgument -> Rep ModelOneArgument x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModelOneArgument x -> ModelOneArgument
$cfrom :: forall x. ModelOneArgument -> Rep ModelOneArgument x
Generic, ModelOneArgument -> Q Exp
ModelOneArgument -> Q (TExp ModelOneArgument)
(ModelOneArgument -> Q Exp)
-> (ModelOneArgument -> Q (TExp ModelOneArgument))
-> Lift ModelOneArgument
forall t. (t -> Q Exp) -> (t -> Q (TExp t)) -> Lift t
liftTyped :: ModelOneArgument -> Q (TExp ModelOneArgument)
$cliftTyped :: ModelOneArgument -> Q (TExp ModelOneArgument)
lift :: ModelOneArgument -> Q Exp
$clift :: ModelOneArgument -> Q Exp
Lift, ModelOneArgument -> ()
(ModelOneArgument -> ()) -> NFData ModelOneArgument
forall a. (a -> ()) -> NFData a
rnf :: ModelOneArgument -> ()
$crnf :: ModelOneArgument -> ()
NFData)
    deriving (Value -> Parser [ModelOneArgument]
Value -> Parser ModelOneArgument
(Value -> Parser ModelOneArgument)
-> (Value -> Parser [ModelOneArgument])
-> FromJSON ModelOneArgument
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ModelOneArgument]
$cparseJSONList :: Value -> Parser [ModelOneArgument]
parseJSON :: Value -> Parser ModelOneArgument
$cparseJSON :: Value -> Parser ModelOneArgument
FromJSON, [ModelOneArgument] -> Encoding
[ModelOneArgument] -> Value
ModelOneArgument -> Encoding
ModelOneArgument -> Value
(ModelOneArgument -> Value)
-> (ModelOneArgument -> Encoding)
-> ([ModelOneArgument] -> Value)
-> ([ModelOneArgument] -> Encoding)
-> ToJSON ModelOneArgument
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ModelOneArgument] -> Encoding
$ctoEncodingList :: [ModelOneArgument] -> Encoding
toJSONList :: [ModelOneArgument] -> Value
$ctoJSONList :: [ModelOneArgument] -> Value
toEncoding :: ModelOneArgument -> Encoding
$ctoEncoding :: ModelOneArgument -> Encoding
toJSON :: ModelOneArgument -> Value
$ctoJSON :: ModelOneArgument -> Value
ToJSON) via CustomJSON
        '[ TagSingleConstructors
         , SumTaggedObject "type" "arguments"
         , ConstructorTagModifier (StripPrefix "ModelOneArgument", CamelToSnake)]
        ModelOneArgument
        -- Without TagSingleConstructors the format can change unexpectedly if
        -- you add/remove constructors because you don't get the tags if there's
        -- only one constructor but you do if there's more than one.
instance Default ModelOneArgument where
    def :: ModelOneArgument
def = CostingInteger -> ModelOneArgument
ModelOneArgumentConstantCost CostingInteger
0

runCostingFunOneArgument
    :: CostingFun ModelOneArgument
    -> ExMemory
    -> ExBudget
runCostingFunOneArgument :: CostingFun ModelOneArgument -> ExMemory -> ExBudget
runCostingFunOneArgument
    (CostingFun ModelOneArgument
cpu ModelOneArgument
mem) ExMemory
mem1 =
        ExCPU -> ExMemory -> ExBudget
ExBudget (CostingInteger -> ExCPU
ExCPU    (CostingInteger -> ExCPU) -> CostingInteger -> ExCPU
forall a b. (a -> b) -> a -> b
$ ModelOneArgument -> ExMemory -> CostingInteger
runOneArgumentModel ModelOneArgument
cpu ExMemory
mem1)
                 (CostingInteger -> ExMemory
ExMemory (CostingInteger -> ExMemory) -> CostingInteger -> ExMemory
forall a b. (a -> b) -> a -> b
$ ModelOneArgument -> ExMemory -> CostingInteger
runOneArgumentModel ModelOneArgument
mem ExMemory
mem1)

runOneArgumentModel
    :: ModelOneArgument
    -> ExMemory
    -> CostingInteger
runOneArgumentModel :: ModelOneArgument -> ExMemory -> CostingInteger
runOneArgumentModel (ModelOneArgumentConstantCost CostingInteger
c) ExMemory
_ = CostingInteger
c
runOneArgumentModel (ModelOneArgumentLinearCost (ModelLinearSize CostingInteger
intercept CostingInteger
slope)) (ExMemory CostingInteger
s) =
    CostingInteger
s CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
* CostingInteger
slope CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
+ CostingInteger
intercept


---------------- Two-argument costing functions ----------------

-- | s * (x + y) + I
data ModelAddedSizes = ModelAddedSizes
    { ModelAddedSizes -> CostingInteger
modelAddedSizesIntercept :: CostingInteger
    , ModelAddedSizes -> CostingInteger
modelAddedSizesSlope     :: CostingInteger
    } deriving (Int -> ModelAddedSizes -> ShowS
[ModelAddedSizes] -> ShowS
ModelAddedSizes -> String
(Int -> ModelAddedSizes -> ShowS)
-> (ModelAddedSizes -> String)
-> ([ModelAddedSizes] -> ShowS)
-> Show ModelAddedSizes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModelAddedSizes] -> ShowS
$cshowList :: [ModelAddedSizes] -> ShowS
show :: ModelAddedSizes -> String
$cshow :: ModelAddedSizes -> String
showsPrec :: Int -> ModelAddedSizes -> ShowS
$cshowsPrec :: Int -> ModelAddedSizes -> ShowS
Show, ModelAddedSizes -> ModelAddedSizes -> Bool
(ModelAddedSizes -> ModelAddedSizes -> Bool)
-> (ModelAddedSizes -> ModelAddedSizes -> Bool)
-> Eq ModelAddedSizes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModelAddedSizes -> ModelAddedSizes -> Bool
$c/= :: ModelAddedSizes -> ModelAddedSizes -> Bool
== :: ModelAddedSizes -> ModelAddedSizes -> Bool
$c== :: ModelAddedSizes -> ModelAddedSizes -> Bool
Eq, (forall x. ModelAddedSizes -> Rep ModelAddedSizes x)
-> (forall x. Rep ModelAddedSizes x -> ModelAddedSizes)
-> Generic ModelAddedSizes
forall x. Rep ModelAddedSizes x -> ModelAddedSizes
forall x. ModelAddedSizes -> Rep ModelAddedSizes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModelAddedSizes x -> ModelAddedSizes
$cfrom :: forall x. ModelAddedSizes -> Rep ModelAddedSizes x
Generic, ModelAddedSizes -> Q Exp
ModelAddedSizes -> Q (TExp ModelAddedSizes)
(ModelAddedSizes -> Q Exp)
-> (ModelAddedSizes -> Q (TExp ModelAddedSizes))
-> Lift ModelAddedSizes
forall t. (t -> Q Exp) -> (t -> Q (TExp t)) -> Lift t
liftTyped :: ModelAddedSizes -> Q (TExp ModelAddedSizes)
$cliftTyped :: ModelAddedSizes -> Q (TExp ModelAddedSizes)
lift :: ModelAddedSizes -> Q Exp
$clift :: ModelAddedSizes -> Q Exp
Lift, ModelAddedSizes -> ()
(ModelAddedSizes -> ()) -> NFData ModelAddedSizes
forall a. (a -> ()) -> NFData a
rnf :: ModelAddedSizes -> ()
$crnf :: ModelAddedSizes -> ()
NFData)
    deriving (Value -> Parser [ModelAddedSizes]
Value -> Parser ModelAddedSizes
(Value -> Parser ModelAddedSizes)
-> (Value -> Parser [ModelAddedSizes]) -> FromJSON ModelAddedSizes
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ModelAddedSizes]
$cparseJSONList :: Value -> Parser [ModelAddedSizes]
parseJSON :: Value -> Parser ModelAddedSizes
$cparseJSON :: Value -> Parser ModelAddedSizes
FromJSON, [ModelAddedSizes] -> Encoding
[ModelAddedSizes] -> Value
ModelAddedSizes -> Encoding
ModelAddedSizes -> Value
(ModelAddedSizes -> Value)
-> (ModelAddedSizes -> Encoding)
-> ([ModelAddedSizes] -> Value)
-> ([ModelAddedSizes] -> Encoding)
-> ToJSON ModelAddedSizes
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ModelAddedSizes] -> Encoding
$ctoEncodingList :: [ModelAddedSizes] -> Encoding
toJSONList :: [ModelAddedSizes] -> Value
$ctoJSONList :: [ModelAddedSizes] -> Value
toEncoding :: ModelAddedSizes -> Encoding
$ctoEncoding :: ModelAddedSizes -> Encoding
toJSON :: ModelAddedSizes -> Value
$ctoJSON :: ModelAddedSizes -> Value
ToJSON) via CustomJSON
        '[FieldLabelModifier (StripPrefix "modelAddedSizes", CamelToSnake)] ModelAddedSizes

-- | s * (x - y) + I
data ModelSubtractedSizes = ModelSubtractedSizes
    { ModelSubtractedSizes -> CostingInteger
modelSubtractedSizesIntercept :: CostingInteger
    , ModelSubtractedSizes -> CostingInteger
modelSubtractedSizesSlope     :: CostingInteger
    , ModelSubtractedSizes -> CostingInteger
modelSubtractedSizesMinimum   :: CostingInteger
    } deriving (Int -> ModelSubtractedSizes -> ShowS
[ModelSubtractedSizes] -> ShowS
ModelSubtractedSizes -> String
(Int -> ModelSubtractedSizes -> ShowS)
-> (ModelSubtractedSizes -> String)
-> ([ModelSubtractedSizes] -> ShowS)
-> Show ModelSubtractedSizes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModelSubtractedSizes] -> ShowS
$cshowList :: [ModelSubtractedSizes] -> ShowS
show :: ModelSubtractedSizes -> String
$cshow :: ModelSubtractedSizes -> String
showsPrec :: Int -> ModelSubtractedSizes -> ShowS
$cshowsPrec :: Int -> ModelSubtractedSizes -> ShowS
Show, ModelSubtractedSizes -> ModelSubtractedSizes -> Bool
(ModelSubtractedSizes -> ModelSubtractedSizes -> Bool)
-> (ModelSubtractedSizes -> ModelSubtractedSizes -> Bool)
-> Eq ModelSubtractedSizes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModelSubtractedSizes -> ModelSubtractedSizes -> Bool
$c/= :: ModelSubtractedSizes -> ModelSubtractedSizes -> Bool
== :: ModelSubtractedSizes -> ModelSubtractedSizes -> Bool
$c== :: ModelSubtractedSizes -> ModelSubtractedSizes -> Bool
Eq, (forall x. ModelSubtractedSizes -> Rep ModelSubtractedSizes x)
-> (forall x. Rep ModelSubtractedSizes x -> ModelSubtractedSizes)
-> Generic ModelSubtractedSizes
forall x. Rep ModelSubtractedSizes x -> ModelSubtractedSizes
forall x. ModelSubtractedSizes -> Rep ModelSubtractedSizes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModelSubtractedSizes x -> ModelSubtractedSizes
$cfrom :: forall x. ModelSubtractedSizes -> Rep ModelSubtractedSizes x
Generic, ModelSubtractedSizes -> Q Exp
ModelSubtractedSizes -> Q (TExp ModelSubtractedSizes)
(ModelSubtractedSizes -> Q Exp)
-> (ModelSubtractedSizes -> Q (TExp ModelSubtractedSizes))
-> Lift ModelSubtractedSizes
forall t. (t -> Q Exp) -> (t -> Q (TExp t)) -> Lift t
liftTyped :: ModelSubtractedSizes -> Q (TExp ModelSubtractedSizes)
$cliftTyped :: ModelSubtractedSizes -> Q (TExp ModelSubtractedSizes)
lift :: ModelSubtractedSizes -> Q Exp
$clift :: ModelSubtractedSizes -> Q Exp
Lift, ModelSubtractedSizes -> ()
(ModelSubtractedSizes -> ()) -> NFData ModelSubtractedSizes
forall a. (a -> ()) -> NFData a
rnf :: ModelSubtractedSizes -> ()
$crnf :: ModelSubtractedSizes -> ()
NFData)
    deriving (Value -> Parser [ModelSubtractedSizes]
Value -> Parser ModelSubtractedSizes
(Value -> Parser ModelSubtractedSizes)
-> (Value -> Parser [ModelSubtractedSizes])
-> FromJSON ModelSubtractedSizes
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ModelSubtractedSizes]
$cparseJSONList :: Value -> Parser [ModelSubtractedSizes]
parseJSON :: Value -> Parser ModelSubtractedSizes
$cparseJSON :: Value -> Parser ModelSubtractedSizes
FromJSON, [ModelSubtractedSizes] -> Encoding
[ModelSubtractedSizes] -> Value
ModelSubtractedSizes -> Encoding
ModelSubtractedSizes -> Value
(ModelSubtractedSizes -> Value)
-> (ModelSubtractedSizes -> Encoding)
-> ([ModelSubtractedSizes] -> Value)
-> ([ModelSubtractedSizes] -> Encoding)
-> ToJSON ModelSubtractedSizes
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ModelSubtractedSizes] -> Encoding
$ctoEncodingList :: [ModelSubtractedSizes] -> Encoding
toJSONList :: [ModelSubtractedSizes] -> Value
$ctoJSONList :: [ModelSubtractedSizes] -> Value
toEncoding :: ModelSubtractedSizes -> Encoding
$ctoEncoding :: ModelSubtractedSizes -> Encoding
toJSON :: ModelSubtractedSizes -> Value
$ctoJSON :: ModelSubtractedSizes -> Value
ToJSON) via CustomJSON
        '[FieldLabelModifier (StripPrefix "modelSubtractedSizes", CamelToSnake)] ModelSubtractedSizes

data ModelLinearSize = ModelLinearSize
    { ModelLinearSize -> CostingInteger
modelLinearSizeIntercept :: CostingInteger
    , ModelLinearSize -> CostingInteger
modelLinearSizeSlope     :: CostingInteger
    } deriving (Int -> ModelLinearSize -> ShowS
[ModelLinearSize] -> ShowS
ModelLinearSize -> String
(Int -> ModelLinearSize -> ShowS)
-> (ModelLinearSize -> String)
-> ([ModelLinearSize] -> ShowS)
-> Show ModelLinearSize
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModelLinearSize] -> ShowS
$cshowList :: [ModelLinearSize] -> ShowS
show :: ModelLinearSize -> String
$cshow :: ModelLinearSize -> String
showsPrec :: Int -> ModelLinearSize -> ShowS
$cshowsPrec :: Int -> ModelLinearSize -> ShowS
Show, ModelLinearSize -> ModelLinearSize -> Bool
(ModelLinearSize -> ModelLinearSize -> Bool)
-> (ModelLinearSize -> ModelLinearSize -> Bool)
-> Eq ModelLinearSize
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModelLinearSize -> ModelLinearSize -> Bool
$c/= :: ModelLinearSize -> ModelLinearSize -> Bool
== :: ModelLinearSize -> ModelLinearSize -> Bool
$c== :: ModelLinearSize -> ModelLinearSize -> Bool
Eq, (forall x. ModelLinearSize -> Rep ModelLinearSize x)
-> (forall x. Rep ModelLinearSize x -> ModelLinearSize)
-> Generic ModelLinearSize
forall x. Rep ModelLinearSize x -> ModelLinearSize
forall x. ModelLinearSize -> Rep ModelLinearSize x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModelLinearSize x -> ModelLinearSize
$cfrom :: forall x. ModelLinearSize -> Rep ModelLinearSize x
Generic, ModelLinearSize -> Q Exp
ModelLinearSize -> Q (TExp ModelLinearSize)
(ModelLinearSize -> Q Exp)
-> (ModelLinearSize -> Q (TExp ModelLinearSize))
-> Lift ModelLinearSize
forall t. (t -> Q Exp) -> (t -> Q (TExp t)) -> Lift t
liftTyped :: ModelLinearSize -> Q (TExp ModelLinearSize)
$cliftTyped :: ModelLinearSize -> Q (TExp ModelLinearSize)
lift :: ModelLinearSize -> Q Exp
$clift :: ModelLinearSize -> Q Exp
Lift, ModelLinearSize -> ()
(ModelLinearSize -> ()) -> NFData ModelLinearSize
forall a. (a -> ()) -> NFData a
rnf :: ModelLinearSize -> ()
$crnf :: ModelLinearSize -> ()
NFData)
    deriving (Value -> Parser [ModelLinearSize]
Value -> Parser ModelLinearSize
(Value -> Parser ModelLinearSize)
-> (Value -> Parser [ModelLinearSize]) -> FromJSON ModelLinearSize
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ModelLinearSize]
$cparseJSONList :: Value -> Parser [ModelLinearSize]
parseJSON :: Value -> Parser ModelLinearSize
$cparseJSON :: Value -> Parser ModelLinearSize
FromJSON, [ModelLinearSize] -> Encoding
[ModelLinearSize] -> Value
ModelLinearSize -> Encoding
ModelLinearSize -> Value
(ModelLinearSize -> Value)
-> (ModelLinearSize -> Encoding)
-> ([ModelLinearSize] -> Value)
-> ([ModelLinearSize] -> Encoding)
-> ToJSON ModelLinearSize
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ModelLinearSize] -> Encoding
$ctoEncodingList :: [ModelLinearSize] -> Encoding
toJSONList :: [ModelLinearSize] -> Value
$ctoJSONList :: [ModelLinearSize] -> Value
toEncoding :: ModelLinearSize -> Encoding
$ctoEncoding :: ModelLinearSize -> Encoding
toJSON :: ModelLinearSize -> Value
$ctoJSON :: ModelLinearSize -> Value
ToJSON) via CustomJSON
        '[FieldLabelModifier (StripPrefix "modelLinearSize", CamelToSnake)] ModelLinearSize

-- | s * (x * y) + I
data ModelMultipliedSizes = ModelMultipliedSizes
    { ModelMultipliedSizes -> CostingInteger
modelMultipliedSizesIntercept :: CostingInteger
    , ModelMultipliedSizes -> CostingInteger
modelMultipliedSizesSlope     :: CostingInteger
    } deriving (Int -> ModelMultipliedSizes -> ShowS
[ModelMultipliedSizes] -> ShowS
ModelMultipliedSizes -> String
(Int -> ModelMultipliedSizes -> ShowS)
-> (ModelMultipliedSizes -> String)
-> ([ModelMultipliedSizes] -> ShowS)
-> Show ModelMultipliedSizes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModelMultipliedSizes] -> ShowS
$cshowList :: [ModelMultipliedSizes] -> ShowS
show :: ModelMultipliedSizes -> String
$cshow :: ModelMultipliedSizes -> String
showsPrec :: Int -> ModelMultipliedSizes -> ShowS
$cshowsPrec :: Int -> ModelMultipliedSizes -> ShowS
Show, ModelMultipliedSizes -> ModelMultipliedSizes -> Bool
(ModelMultipliedSizes -> ModelMultipliedSizes -> Bool)
-> (ModelMultipliedSizes -> ModelMultipliedSizes -> Bool)
-> Eq ModelMultipliedSizes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModelMultipliedSizes -> ModelMultipliedSizes -> Bool
$c/= :: ModelMultipliedSizes -> ModelMultipliedSizes -> Bool
== :: ModelMultipliedSizes -> ModelMultipliedSizes -> Bool
$c== :: ModelMultipliedSizes -> ModelMultipliedSizes -> Bool
Eq, (forall x. ModelMultipliedSizes -> Rep ModelMultipliedSizes x)
-> (forall x. Rep ModelMultipliedSizes x -> ModelMultipliedSizes)
-> Generic ModelMultipliedSizes
forall x. Rep ModelMultipliedSizes x -> ModelMultipliedSizes
forall x. ModelMultipliedSizes -> Rep ModelMultipliedSizes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModelMultipliedSizes x -> ModelMultipliedSizes
$cfrom :: forall x. ModelMultipliedSizes -> Rep ModelMultipliedSizes x
Generic, ModelMultipliedSizes -> Q Exp
ModelMultipliedSizes -> Q (TExp ModelMultipliedSizes)
(ModelMultipliedSizes -> Q Exp)
-> (ModelMultipliedSizes -> Q (TExp ModelMultipliedSizes))
-> Lift ModelMultipliedSizes
forall t. (t -> Q Exp) -> (t -> Q (TExp t)) -> Lift t
liftTyped :: ModelMultipliedSizes -> Q (TExp ModelMultipliedSizes)
$cliftTyped :: ModelMultipliedSizes -> Q (TExp ModelMultipliedSizes)
lift :: ModelMultipliedSizes -> Q Exp
$clift :: ModelMultipliedSizes -> Q Exp
Lift, ModelMultipliedSizes -> ()
(ModelMultipliedSizes -> ()) -> NFData ModelMultipliedSizes
forall a. (a -> ()) -> NFData a
rnf :: ModelMultipliedSizes -> ()
$crnf :: ModelMultipliedSizes -> ()
NFData)
    deriving (Value -> Parser [ModelMultipliedSizes]
Value -> Parser ModelMultipliedSizes
(Value -> Parser ModelMultipliedSizes)
-> (Value -> Parser [ModelMultipliedSizes])
-> FromJSON ModelMultipliedSizes
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ModelMultipliedSizes]
$cparseJSONList :: Value -> Parser [ModelMultipliedSizes]
parseJSON :: Value -> Parser ModelMultipliedSizes
$cparseJSON :: Value -> Parser ModelMultipliedSizes
FromJSON, [ModelMultipliedSizes] -> Encoding
[ModelMultipliedSizes] -> Value
ModelMultipliedSizes -> Encoding
ModelMultipliedSizes -> Value
(ModelMultipliedSizes -> Value)
-> (ModelMultipliedSizes -> Encoding)
-> ([ModelMultipliedSizes] -> Value)
-> ([ModelMultipliedSizes] -> Encoding)
-> ToJSON ModelMultipliedSizes
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ModelMultipliedSizes] -> Encoding
$ctoEncodingList :: [ModelMultipliedSizes] -> Encoding
toJSONList :: [ModelMultipliedSizes] -> Value
$ctoJSONList :: [ModelMultipliedSizes] -> Value
toEncoding :: ModelMultipliedSizes -> Encoding
$ctoEncoding :: ModelMultipliedSizes -> Encoding
toJSON :: ModelMultipliedSizes -> Value
$ctoJSON :: ModelMultipliedSizes -> Value
ToJSON) via CustomJSON
        '[FieldLabelModifier (StripPrefix "modelMultipliedSizes", CamelToSnake)] ModelMultipliedSizes

-- | s * min(x, y) + I
data ModelMinSize = ModelMinSize
    { ModelMinSize -> CostingInteger
modelMinSizeIntercept :: CostingInteger
    , ModelMinSize -> CostingInteger
modelMinSizeSlope     :: CostingInteger
    } deriving (Int -> ModelMinSize -> ShowS
[ModelMinSize] -> ShowS
ModelMinSize -> String
(Int -> ModelMinSize -> ShowS)
-> (ModelMinSize -> String)
-> ([ModelMinSize] -> ShowS)
-> Show ModelMinSize
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModelMinSize] -> ShowS
$cshowList :: [ModelMinSize] -> ShowS
show :: ModelMinSize -> String
$cshow :: ModelMinSize -> String
showsPrec :: Int -> ModelMinSize -> ShowS
$cshowsPrec :: Int -> ModelMinSize -> ShowS
Show, ModelMinSize -> ModelMinSize -> Bool
(ModelMinSize -> ModelMinSize -> Bool)
-> (ModelMinSize -> ModelMinSize -> Bool) -> Eq ModelMinSize
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModelMinSize -> ModelMinSize -> Bool
$c/= :: ModelMinSize -> ModelMinSize -> Bool
== :: ModelMinSize -> ModelMinSize -> Bool
$c== :: ModelMinSize -> ModelMinSize -> Bool
Eq, (forall x. ModelMinSize -> Rep ModelMinSize x)
-> (forall x. Rep ModelMinSize x -> ModelMinSize)
-> Generic ModelMinSize
forall x. Rep ModelMinSize x -> ModelMinSize
forall x. ModelMinSize -> Rep ModelMinSize x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModelMinSize x -> ModelMinSize
$cfrom :: forall x. ModelMinSize -> Rep ModelMinSize x
Generic, ModelMinSize -> Q Exp
ModelMinSize -> Q (TExp ModelMinSize)
(ModelMinSize -> Q Exp)
-> (ModelMinSize -> Q (TExp ModelMinSize)) -> Lift ModelMinSize
forall t. (t -> Q Exp) -> (t -> Q (TExp t)) -> Lift t
liftTyped :: ModelMinSize -> Q (TExp ModelMinSize)
$cliftTyped :: ModelMinSize -> Q (TExp ModelMinSize)
lift :: ModelMinSize -> Q Exp
$clift :: ModelMinSize -> Q Exp
Lift, ModelMinSize -> ()
(ModelMinSize -> ()) -> NFData ModelMinSize
forall a. (a -> ()) -> NFData a
rnf :: ModelMinSize -> ()
$crnf :: ModelMinSize -> ()
NFData)
    deriving (Value -> Parser [ModelMinSize]
Value -> Parser ModelMinSize
(Value -> Parser ModelMinSize)
-> (Value -> Parser [ModelMinSize]) -> FromJSON ModelMinSize
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ModelMinSize]
$cparseJSONList :: Value -> Parser [ModelMinSize]
parseJSON :: Value -> Parser ModelMinSize
$cparseJSON :: Value -> Parser ModelMinSize
FromJSON, [ModelMinSize] -> Encoding
[ModelMinSize] -> Value
ModelMinSize -> Encoding
ModelMinSize -> Value
(ModelMinSize -> Value)
-> (ModelMinSize -> Encoding)
-> ([ModelMinSize] -> Value)
-> ([ModelMinSize] -> Encoding)
-> ToJSON ModelMinSize
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ModelMinSize] -> Encoding
$ctoEncodingList :: [ModelMinSize] -> Encoding
toJSONList :: [ModelMinSize] -> Value
$ctoJSONList :: [ModelMinSize] -> Value
toEncoding :: ModelMinSize -> Encoding
$ctoEncoding :: ModelMinSize -> Encoding
toJSON :: ModelMinSize -> Value
$ctoJSON :: ModelMinSize -> Value
ToJSON) via CustomJSON
        '[FieldLabelModifier (StripPrefix "modelMinSize", CamelToSnake)] ModelMinSize

-- | s * max(x, y) + I
data ModelMaxSize = ModelMaxSize
    { ModelMaxSize -> CostingInteger
modelMaxSizeIntercept :: CostingInteger
    , ModelMaxSize -> CostingInteger
modelMaxSizeSlope     :: CostingInteger
    } deriving (Int -> ModelMaxSize -> ShowS
[ModelMaxSize] -> ShowS
ModelMaxSize -> String
(Int -> ModelMaxSize -> ShowS)
-> (ModelMaxSize -> String)
-> ([ModelMaxSize] -> ShowS)
-> Show ModelMaxSize
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModelMaxSize] -> ShowS
$cshowList :: [ModelMaxSize] -> ShowS
show :: ModelMaxSize -> String
$cshow :: ModelMaxSize -> String
showsPrec :: Int -> ModelMaxSize -> ShowS
$cshowsPrec :: Int -> ModelMaxSize -> ShowS
Show, ModelMaxSize -> ModelMaxSize -> Bool
(ModelMaxSize -> ModelMaxSize -> Bool)
-> (ModelMaxSize -> ModelMaxSize -> Bool) -> Eq ModelMaxSize
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModelMaxSize -> ModelMaxSize -> Bool
$c/= :: ModelMaxSize -> ModelMaxSize -> Bool
== :: ModelMaxSize -> ModelMaxSize -> Bool
$c== :: ModelMaxSize -> ModelMaxSize -> Bool
Eq, (forall x. ModelMaxSize -> Rep ModelMaxSize x)
-> (forall x. Rep ModelMaxSize x -> ModelMaxSize)
-> Generic ModelMaxSize
forall x. Rep ModelMaxSize x -> ModelMaxSize
forall x. ModelMaxSize -> Rep ModelMaxSize x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModelMaxSize x -> ModelMaxSize
$cfrom :: forall x. ModelMaxSize -> Rep ModelMaxSize x
Generic, ModelMaxSize -> Q Exp
ModelMaxSize -> Q (TExp ModelMaxSize)
(ModelMaxSize -> Q Exp)
-> (ModelMaxSize -> Q (TExp ModelMaxSize)) -> Lift ModelMaxSize
forall t. (t -> Q Exp) -> (t -> Q (TExp t)) -> Lift t
liftTyped :: ModelMaxSize -> Q (TExp ModelMaxSize)
$cliftTyped :: ModelMaxSize -> Q (TExp ModelMaxSize)
lift :: ModelMaxSize -> Q Exp
$clift :: ModelMaxSize -> Q Exp
Lift, ModelMaxSize -> ()
(ModelMaxSize -> ()) -> NFData ModelMaxSize
forall a. (a -> ()) -> NFData a
rnf :: ModelMaxSize -> ()
$crnf :: ModelMaxSize -> ()
NFData)
    deriving (Value -> Parser [ModelMaxSize]
Value -> Parser ModelMaxSize
(Value -> Parser ModelMaxSize)
-> (Value -> Parser [ModelMaxSize]) -> FromJSON ModelMaxSize
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ModelMaxSize]
$cparseJSONList :: Value -> Parser [ModelMaxSize]
parseJSON :: Value -> Parser ModelMaxSize
$cparseJSON :: Value -> Parser ModelMaxSize
FromJSON, [ModelMaxSize] -> Encoding
[ModelMaxSize] -> Value
ModelMaxSize -> Encoding
ModelMaxSize -> Value
(ModelMaxSize -> Value)
-> (ModelMaxSize -> Encoding)
-> ([ModelMaxSize] -> Value)
-> ([ModelMaxSize] -> Encoding)
-> ToJSON ModelMaxSize
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ModelMaxSize] -> Encoding
$ctoEncodingList :: [ModelMaxSize] -> Encoding
toJSONList :: [ModelMaxSize] -> Value
$ctoJSONList :: [ModelMaxSize] -> Value
toEncoding :: ModelMaxSize -> Encoding
$ctoEncoding :: ModelMaxSize -> Encoding
toJSON :: ModelMaxSize -> Value
$ctoJSON :: ModelMaxSize -> Value
ToJSON) via CustomJSON
        '[FieldLabelModifier (StripPrefix "modelMaxSize", CamelToSnake)] ModelMaxSize

-- | if p then s*x else c; p depends on usage
data ModelConstantOrLinear = ModelConstantOrLinear
    { ModelConstantOrLinear -> CostingInteger
modelConstantOrLinearConstant  :: CostingInteger
    , ModelConstantOrLinear -> CostingInteger
modelConstantOrLinearIntercept :: CostingInteger
    , ModelConstantOrLinear -> CostingInteger
modelConstantOrLinearSlope     :: CostingInteger
    } deriving (Int -> ModelConstantOrLinear -> ShowS
[ModelConstantOrLinear] -> ShowS
ModelConstantOrLinear -> String
(Int -> ModelConstantOrLinear -> ShowS)
-> (ModelConstantOrLinear -> String)
-> ([ModelConstantOrLinear] -> ShowS)
-> Show ModelConstantOrLinear
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModelConstantOrLinear] -> ShowS
$cshowList :: [ModelConstantOrLinear] -> ShowS
show :: ModelConstantOrLinear -> String
$cshow :: ModelConstantOrLinear -> String
showsPrec :: Int -> ModelConstantOrLinear -> ShowS
$cshowsPrec :: Int -> ModelConstantOrLinear -> ShowS
Show, ModelConstantOrLinear -> ModelConstantOrLinear -> Bool
(ModelConstantOrLinear -> ModelConstantOrLinear -> Bool)
-> (ModelConstantOrLinear -> ModelConstantOrLinear -> Bool)
-> Eq ModelConstantOrLinear
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModelConstantOrLinear -> ModelConstantOrLinear -> Bool
$c/= :: ModelConstantOrLinear -> ModelConstantOrLinear -> Bool
== :: ModelConstantOrLinear -> ModelConstantOrLinear -> Bool
$c== :: ModelConstantOrLinear -> ModelConstantOrLinear -> Bool
Eq, (forall x. ModelConstantOrLinear -> Rep ModelConstantOrLinear x)
-> (forall x. Rep ModelConstantOrLinear x -> ModelConstantOrLinear)
-> Generic ModelConstantOrLinear
forall x. Rep ModelConstantOrLinear x -> ModelConstantOrLinear
forall x. ModelConstantOrLinear -> Rep ModelConstantOrLinear x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModelConstantOrLinear x -> ModelConstantOrLinear
$cfrom :: forall x. ModelConstantOrLinear -> Rep ModelConstantOrLinear x
Generic, ModelConstantOrLinear -> Q Exp
ModelConstantOrLinear -> Q (TExp ModelConstantOrLinear)
(ModelConstantOrLinear -> Q Exp)
-> (ModelConstantOrLinear -> Q (TExp ModelConstantOrLinear))
-> Lift ModelConstantOrLinear
forall t. (t -> Q Exp) -> (t -> Q (TExp t)) -> Lift t
liftTyped :: ModelConstantOrLinear -> Q (TExp ModelConstantOrLinear)
$cliftTyped :: ModelConstantOrLinear -> Q (TExp ModelConstantOrLinear)
lift :: ModelConstantOrLinear -> Q Exp
$clift :: ModelConstantOrLinear -> Q Exp
Lift, ModelConstantOrLinear -> ()
(ModelConstantOrLinear -> ()) -> NFData ModelConstantOrLinear
forall a. (a -> ()) -> NFData a
rnf :: ModelConstantOrLinear -> ()
$crnf :: ModelConstantOrLinear -> ()
NFData)
    deriving (Value -> Parser [ModelConstantOrLinear]
Value -> Parser ModelConstantOrLinear
(Value -> Parser ModelConstantOrLinear)
-> (Value -> Parser [ModelConstantOrLinear])
-> FromJSON ModelConstantOrLinear
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ModelConstantOrLinear]
$cparseJSONList :: Value -> Parser [ModelConstantOrLinear]
parseJSON :: Value -> Parser ModelConstantOrLinear
$cparseJSON :: Value -> Parser ModelConstantOrLinear
FromJSON, [ModelConstantOrLinear] -> Encoding
[ModelConstantOrLinear] -> Value
ModelConstantOrLinear -> Encoding
ModelConstantOrLinear -> Value
(ModelConstantOrLinear -> Value)
-> (ModelConstantOrLinear -> Encoding)
-> ([ModelConstantOrLinear] -> Value)
-> ([ModelConstantOrLinear] -> Encoding)
-> ToJSON ModelConstantOrLinear
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ModelConstantOrLinear] -> Encoding
$ctoEncodingList :: [ModelConstantOrLinear] -> Encoding
toJSONList :: [ModelConstantOrLinear] -> Value
$ctoJSONList :: [ModelConstantOrLinear] -> Value
toEncoding :: ModelConstantOrLinear -> Encoding
$ctoEncoding :: ModelConstantOrLinear -> Encoding
toJSON :: ModelConstantOrLinear -> Value
$ctoJSON :: ModelConstantOrLinear -> Value
ToJSON) via CustomJSON
        '[FieldLabelModifier (StripPrefix "modelConstantOrLinear", CamelToSnake)] ModelConstantOrLinear

-- | if p then f(x,y) else c; p depends on usage
data ModelConstantOrTwoArguments = ModelConstantOrTwoArguments
    { ModelConstantOrTwoArguments -> CostingInteger
modelConstantOrTwoArgumentsConstant :: CostingInteger
    , ModelConstantOrTwoArguments -> ModelTwoArguments
modelConstantOrTwoArgumentsModel    :: ModelTwoArguments
    } deriving (Int -> ModelConstantOrTwoArguments -> ShowS
[ModelConstantOrTwoArguments] -> ShowS
ModelConstantOrTwoArguments -> String
(Int -> ModelConstantOrTwoArguments -> ShowS)
-> (ModelConstantOrTwoArguments -> String)
-> ([ModelConstantOrTwoArguments] -> ShowS)
-> Show ModelConstantOrTwoArguments
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModelConstantOrTwoArguments] -> ShowS
$cshowList :: [ModelConstantOrTwoArguments] -> ShowS
show :: ModelConstantOrTwoArguments -> String
$cshow :: ModelConstantOrTwoArguments -> String
showsPrec :: Int -> ModelConstantOrTwoArguments -> ShowS
$cshowsPrec :: Int -> ModelConstantOrTwoArguments -> ShowS
Show, ModelConstantOrTwoArguments -> ModelConstantOrTwoArguments -> Bool
(ModelConstantOrTwoArguments
 -> ModelConstantOrTwoArguments -> Bool)
-> (ModelConstantOrTwoArguments
    -> ModelConstantOrTwoArguments -> Bool)
-> Eq ModelConstantOrTwoArguments
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModelConstantOrTwoArguments -> ModelConstantOrTwoArguments -> Bool
$c/= :: ModelConstantOrTwoArguments -> ModelConstantOrTwoArguments -> Bool
== :: ModelConstantOrTwoArguments -> ModelConstantOrTwoArguments -> Bool
$c== :: ModelConstantOrTwoArguments -> ModelConstantOrTwoArguments -> Bool
Eq, (forall x.
 ModelConstantOrTwoArguments -> Rep ModelConstantOrTwoArguments x)
-> (forall x.
    Rep ModelConstantOrTwoArguments x -> ModelConstantOrTwoArguments)
-> Generic ModelConstantOrTwoArguments
forall x.
Rep ModelConstantOrTwoArguments x -> ModelConstantOrTwoArguments
forall x.
ModelConstantOrTwoArguments -> Rep ModelConstantOrTwoArguments x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ModelConstantOrTwoArguments x -> ModelConstantOrTwoArguments
$cfrom :: forall x.
ModelConstantOrTwoArguments -> Rep ModelConstantOrTwoArguments x
Generic, ModelConstantOrTwoArguments -> Q Exp
ModelConstantOrTwoArguments -> Q (TExp ModelConstantOrTwoArguments)
(ModelConstantOrTwoArguments -> Q Exp)
-> (ModelConstantOrTwoArguments
    -> Q (TExp ModelConstantOrTwoArguments))
-> Lift ModelConstantOrTwoArguments
forall t. (t -> Q Exp) -> (t -> Q (TExp t)) -> Lift t
liftTyped :: ModelConstantOrTwoArguments -> Q (TExp ModelConstantOrTwoArguments)
$cliftTyped :: ModelConstantOrTwoArguments -> Q (TExp ModelConstantOrTwoArguments)
lift :: ModelConstantOrTwoArguments -> Q Exp
$clift :: ModelConstantOrTwoArguments -> Q Exp
Lift, ModelConstantOrTwoArguments -> ()
(ModelConstantOrTwoArguments -> ())
-> NFData ModelConstantOrTwoArguments
forall a. (a -> ()) -> NFData a
rnf :: ModelConstantOrTwoArguments -> ()
$crnf :: ModelConstantOrTwoArguments -> ()
NFData)
    deriving (Value -> Parser [ModelConstantOrTwoArguments]
Value -> Parser ModelConstantOrTwoArguments
(Value -> Parser ModelConstantOrTwoArguments)
-> (Value -> Parser [ModelConstantOrTwoArguments])
-> FromJSON ModelConstantOrTwoArguments
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ModelConstantOrTwoArguments]
$cparseJSONList :: Value -> Parser [ModelConstantOrTwoArguments]
parseJSON :: Value -> Parser ModelConstantOrTwoArguments
$cparseJSON :: Value -> Parser ModelConstantOrTwoArguments
FromJSON, [ModelConstantOrTwoArguments] -> Encoding
[ModelConstantOrTwoArguments] -> Value
ModelConstantOrTwoArguments -> Encoding
ModelConstantOrTwoArguments -> Value
(ModelConstantOrTwoArguments -> Value)
-> (ModelConstantOrTwoArguments -> Encoding)
-> ([ModelConstantOrTwoArguments] -> Value)
-> ([ModelConstantOrTwoArguments] -> Encoding)
-> ToJSON ModelConstantOrTwoArguments
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ModelConstantOrTwoArguments] -> Encoding
$ctoEncodingList :: [ModelConstantOrTwoArguments] -> Encoding
toJSONList :: [ModelConstantOrTwoArguments] -> Value
$ctoJSONList :: [ModelConstantOrTwoArguments] -> Value
toEncoding :: ModelConstantOrTwoArguments -> Encoding
$ctoEncoding :: ModelConstantOrTwoArguments -> Encoding
toJSON :: ModelConstantOrTwoArguments -> Value
$ctoJSON :: ModelConstantOrTwoArguments -> Value
ToJSON) via CustomJSON
        '[FieldLabelModifier (StripPrefix "modelConstantOrTwoArguments", CamelToSnake)] ModelConstantOrTwoArguments


data ModelTwoArguments =
    ModelTwoArgumentsConstantCost       CostingInteger
  | ModelTwoArgumentsLinearInX          ModelLinearSize
  | ModelTwoArgumentsLinearInY          ModelLinearSize
  | ModelTwoArgumentsAddedSizes         ModelAddedSizes
  | ModelTwoArgumentsSubtractedSizes    ModelSubtractedSizes
  | ModelTwoArgumentsMultipliedSizes    ModelMultipliedSizes
  | ModelTwoArgumentsMinSize            ModelMinSize
  | ModelTwoArgumentsMaxSize            ModelMaxSize
  | ModelTwoArgumentsLinearOnDiagonal   ModelConstantOrLinear
  | ModelTwoArgumentsConstAboveDiagonal ModelConstantOrTwoArguments
  | ModelTwoArgumentsConstBelowDiagonal ModelConstantOrTwoArguments
    deriving (Int -> ModelTwoArguments -> ShowS
[ModelTwoArguments] -> ShowS
ModelTwoArguments -> String
(Int -> ModelTwoArguments -> ShowS)
-> (ModelTwoArguments -> String)
-> ([ModelTwoArguments] -> ShowS)
-> Show ModelTwoArguments
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModelTwoArguments] -> ShowS
$cshowList :: [ModelTwoArguments] -> ShowS
show :: ModelTwoArguments -> String
$cshow :: ModelTwoArguments -> String
showsPrec :: Int -> ModelTwoArguments -> ShowS
$cshowsPrec :: Int -> ModelTwoArguments -> ShowS
Show, ModelTwoArguments -> ModelTwoArguments -> Bool
(ModelTwoArguments -> ModelTwoArguments -> Bool)
-> (ModelTwoArguments -> ModelTwoArguments -> Bool)
-> Eq ModelTwoArguments
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModelTwoArguments -> ModelTwoArguments -> Bool
$c/= :: ModelTwoArguments -> ModelTwoArguments -> Bool
== :: ModelTwoArguments -> ModelTwoArguments -> Bool
$c== :: ModelTwoArguments -> ModelTwoArguments -> Bool
Eq, (forall x. ModelTwoArguments -> Rep ModelTwoArguments x)
-> (forall x. Rep ModelTwoArguments x -> ModelTwoArguments)
-> Generic ModelTwoArguments
forall x. Rep ModelTwoArguments x -> ModelTwoArguments
forall x. ModelTwoArguments -> Rep ModelTwoArguments x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModelTwoArguments x -> ModelTwoArguments
$cfrom :: forall x. ModelTwoArguments -> Rep ModelTwoArguments x
Generic, ModelTwoArguments -> Q Exp
ModelTwoArguments -> Q (TExp ModelTwoArguments)
(ModelTwoArguments -> Q Exp)
-> (ModelTwoArguments -> Q (TExp ModelTwoArguments))
-> Lift ModelTwoArguments
forall t. (t -> Q Exp) -> (t -> Q (TExp t)) -> Lift t
liftTyped :: ModelTwoArguments -> Q (TExp ModelTwoArguments)
$cliftTyped :: ModelTwoArguments -> Q (TExp ModelTwoArguments)
lift :: ModelTwoArguments -> Q Exp
$clift :: ModelTwoArguments -> Q Exp
Lift, ModelTwoArguments -> ()
(ModelTwoArguments -> ()) -> NFData ModelTwoArguments
forall a. (a -> ()) -> NFData a
rnf :: ModelTwoArguments -> ()
$crnf :: ModelTwoArguments -> ()
NFData)
    deriving (Value -> Parser [ModelTwoArguments]
Value -> Parser ModelTwoArguments
(Value -> Parser ModelTwoArguments)
-> (Value -> Parser [ModelTwoArguments])
-> FromJSON ModelTwoArguments
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ModelTwoArguments]
$cparseJSONList :: Value -> Parser [ModelTwoArguments]
parseJSON :: Value -> Parser ModelTwoArguments
$cparseJSON :: Value -> Parser ModelTwoArguments
FromJSON, [ModelTwoArguments] -> Encoding
[ModelTwoArguments] -> Value
ModelTwoArguments -> Encoding
ModelTwoArguments -> Value
(ModelTwoArguments -> Value)
-> (ModelTwoArguments -> Encoding)
-> ([ModelTwoArguments] -> Value)
-> ([ModelTwoArguments] -> Encoding)
-> ToJSON ModelTwoArguments
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ModelTwoArguments] -> Encoding
$ctoEncodingList :: [ModelTwoArguments] -> Encoding
toJSONList :: [ModelTwoArguments] -> Value
$ctoJSONList :: [ModelTwoArguments] -> Value
toEncoding :: ModelTwoArguments -> Encoding
$ctoEncoding :: ModelTwoArguments -> Encoding
toJSON :: ModelTwoArguments -> Value
$ctoJSON :: ModelTwoArguments -> Value
ToJSON) via CustomJSON
        '[ TagSingleConstructors
         , SumTaggedObject "type" "arguments"
         , ConstructorTagModifier (StripPrefix "ModelTwoArguments", CamelToSnake)]
        ModelTwoArguments

instance Default ModelTwoArguments where
    def :: ModelTwoArguments
def = CostingInteger -> ModelTwoArguments
ModelTwoArgumentsConstantCost CostingInteger
0

runCostingFunTwoArguments
    :: CostingFun ModelTwoArguments
    -> ExMemory
    -> ExMemory
    -> ExBudget
runCostingFunTwoArguments :: CostingFun ModelTwoArguments -> ExMemory -> ExMemory -> ExBudget
runCostingFunTwoArguments (CostingFun ModelTwoArguments
cpu ModelTwoArguments
mem) ExMemory
mem1 ExMemory
mem2 =
    ExCPU -> ExMemory -> ExBudget
ExBudget (CostingInteger -> ExCPU
ExCPU    (CostingInteger -> ExCPU) -> CostingInteger -> ExCPU
forall a b. (a -> b) -> a -> b
$ ModelTwoArguments -> ExMemory -> ExMemory -> CostingInteger
runTwoArgumentModel ModelTwoArguments
cpu ExMemory
mem1 ExMemory
mem2)
             (CostingInteger -> ExMemory
ExMemory (CostingInteger -> ExMemory) -> CostingInteger -> ExMemory
forall a b. (a -> b) -> a -> b
$ ModelTwoArguments -> ExMemory -> ExMemory -> CostingInteger
runTwoArgumentModel ModelTwoArguments
mem ExMemory
mem1 ExMemory
mem2)

runTwoArgumentModel
    :: ModelTwoArguments
    -> ExMemory
    -> ExMemory
    -> CostingInteger
runTwoArgumentModel :: ModelTwoArguments -> ExMemory -> ExMemory -> CostingInteger
runTwoArgumentModel
    (ModelTwoArgumentsConstantCost CostingInteger
c) ExMemory
_ ExMemory
_ = CostingInteger
c
runTwoArgumentModel
    (ModelTwoArgumentsAddedSizes (ModelAddedSizes CostingInteger
intercept CostingInteger
slope)) (ExMemory CostingInteger
size1) (ExMemory CostingInteger
size2) =
        (CostingInteger
size1 CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
+ CostingInteger
size2) CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
* CostingInteger
slope CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
+ CostingInteger
intercept -- TODO is this even correct? If not, adjust the other implementations too.
runTwoArgumentModel
    (ModelTwoArgumentsSubtractedSizes (ModelSubtractedSizes CostingInteger
intercept CostingInteger
slope CostingInteger
minSize)) (ExMemory CostingInteger
size1) (ExMemory CostingInteger
size2) =
        (CostingInteger -> CostingInteger -> CostingInteger
forall a. Ord a => a -> a -> a
max CostingInteger
minSize (CostingInteger
size1 CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
- CostingInteger
size2)) CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
* CostingInteger
slope CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
+ CostingInteger
intercept
runTwoArgumentModel
    (ModelTwoArgumentsMultipliedSizes (ModelMultipliedSizes CostingInteger
intercept CostingInteger
slope)) (ExMemory CostingInteger
size1) (ExMemory CostingInteger
size2) =
        (CostingInteger
size1 CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
* CostingInteger
size2) CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
* CostingInteger
slope CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
+ CostingInteger
intercept
runTwoArgumentModel
    (ModelTwoArgumentsMinSize (ModelMinSize CostingInteger
intercept CostingInteger
slope)) (ExMemory CostingInteger
size1) (ExMemory CostingInteger
size2) =
        (CostingInteger -> CostingInteger -> CostingInteger
forall a. Ord a => a -> a -> a
min CostingInteger
size1 CostingInteger
size2) CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
* CostingInteger
slope CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
+ CostingInteger
intercept
runTwoArgumentModel
    (ModelTwoArgumentsMaxSize (ModelMaxSize CostingInteger
intercept CostingInteger
slope)) (ExMemory CostingInteger
size1) (ExMemory CostingInteger
size2) =
        (CostingInteger -> CostingInteger -> CostingInteger
forall a. Ord a => a -> a -> a
max CostingInteger
size1 CostingInteger
size2) CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
* CostingInteger
slope CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
+ CostingInteger
intercept
runTwoArgumentModel
    (ModelTwoArgumentsLinearInX (ModelLinearSize CostingInteger
intercept CostingInteger
slope)) (ExMemory CostingInteger
size1) (ExMemory CostingInteger
_) =
        CostingInteger
size1 CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
* CostingInteger
slope CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
+ CostingInteger
intercept
runTwoArgumentModel
    (ModelTwoArgumentsLinearInY (ModelLinearSize CostingInteger
intercept CostingInteger
slope)) (ExMemory CostingInteger
_) (ExMemory CostingInteger
size2) =
        CostingInteger
size2 CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
* CostingInteger
slope CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
+ CostingInteger
intercept
runTwoArgumentModel  -- Off the diagonal, return the constant.  On the diagonal, run the one-variable linear model.
    (ModelTwoArgumentsLinearOnDiagonal (ModelConstantOrLinear CostingInteger
c CostingInteger
intercept CostingInteger
slope)) (ExMemory CostingInteger
xSize) (ExMemory CostingInteger
ySize) =
        if CostingInteger
xSize CostingInteger -> CostingInteger -> Bool
forall a. Eq a => a -> a -> Bool
== CostingInteger
ySize
        then CostingInteger
xSize CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
* CostingInteger
slope CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
+ CostingInteger
intercept
        else CostingInteger
c
runTwoArgumentModel -- Below the diagonal, return the constant. Above the diagonal, run the other model.
    (ModelTwoArgumentsConstBelowDiagonal (ModelConstantOrTwoArguments CostingInteger
c ModelTwoArguments
m)) ExMemory
xMem ExMemory
yMem =
        if ExMemory
xMem ExMemory -> ExMemory -> Bool
forall a. Ord a => a -> a -> Bool
> ExMemory
yMem
        then CostingInteger
c
        else ModelTwoArguments -> ExMemory -> ExMemory -> CostingInteger
runTwoArgumentModel ModelTwoArguments
m ExMemory
xMem ExMemory
yMem
runTwoArgumentModel -- Above the diagonal, return the constant. Below the diagonal, run the other model.
    (ModelTwoArgumentsConstAboveDiagonal (ModelConstantOrTwoArguments CostingInteger
c ModelTwoArguments
m)) ExMemory
xMem ExMemory
yMem =
        if ExMemory
xMem ExMemory -> ExMemory -> Bool
forall a. Ord a => a -> a -> Bool
< ExMemory
yMem
        then CostingInteger
c
        else ModelTwoArguments -> ExMemory -> ExMemory -> CostingInteger
runTwoArgumentModel ModelTwoArguments
m ExMemory
xMem ExMemory
yMem


---------------- Three-argument costing functions ----------------

data ModelThreeArguments =
    ModelThreeArgumentsConstantCost CostingInteger
  | ModelThreeArgumentsAddedSizes   ModelAddedSizes
  | ModelThreeArgumentsLinearInX    ModelLinearSize
  | ModelThreeArgumentsLinearInY    ModelLinearSize
  | ModelThreeArgumentsLinearInZ    ModelLinearSize
    deriving (Int -> ModelThreeArguments -> ShowS
[ModelThreeArguments] -> ShowS
ModelThreeArguments -> String
(Int -> ModelThreeArguments -> ShowS)
-> (ModelThreeArguments -> String)
-> ([ModelThreeArguments] -> ShowS)
-> Show ModelThreeArguments
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModelThreeArguments] -> ShowS
$cshowList :: [ModelThreeArguments] -> ShowS
show :: ModelThreeArguments -> String
$cshow :: ModelThreeArguments -> String
showsPrec :: Int -> ModelThreeArguments -> ShowS
$cshowsPrec :: Int -> ModelThreeArguments -> ShowS
Show, ModelThreeArguments -> ModelThreeArguments -> Bool
(ModelThreeArguments -> ModelThreeArguments -> Bool)
-> (ModelThreeArguments -> ModelThreeArguments -> Bool)
-> Eq ModelThreeArguments
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModelThreeArguments -> ModelThreeArguments -> Bool
$c/= :: ModelThreeArguments -> ModelThreeArguments -> Bool
== :: ModelThreeArguments -> ModelThreeArguments -> Bool
$c== :: ModelThreeArguments -> ModelThreeArguments -> Bool
Eq, (forall x. ModelThreeArguments -> Rep ModelThreeArguments x)
-> (forall x. Rep ModelThreeArguments x -> ModelThreeArguments)
-> Generic ModelThreeArguments
forall x. Rep ModelThreeArguments x -> ModelThreeArguments
forall x. ModelThreeArguments -> Rep ModelThreeArguments x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModelThreeArguments x -> ModelThreeArguments
$cfrom :: forall x. ModelThreeArguments -> Rep ModelThreeArguments x
Generic, ModelThreeArguments -> Q Exp
ModelThreeArguments -> Q (TExp ModelThreeArguments)
(ModelThreeArguments -> Q Exp)
-> (ModelThreeArguments -> Q (TExp ModelThreeArguments))
-> Lift ModelThreeArguments
forall t. (t -> Q Exp) -> (t -> Q (TExp t)) -> Lift t
liftTyped :: ModelThreeArguments -> Q (TExp ModelThreeArguments)
$cliftTyped :: ModelThreeArguments -> Q (TExp ModelThreeArguments)
lift :: ModelThreeArguments -> Q Exp
$clift :: ModelThreeArguments -> Q Exp
Lift, ModelThreeArguments -> ()
(ModelThreeArguments -> ()) -> NFData ModelThreeArguments
forall a. (a -> ()) -> NFData a
rnf :: ModelThreeArguments -> ()
$crnf :: ModelThreeArguments -> ()
NFData)
    deriving (Value -> Parser [ModelThreeArguments]
Value -> Parser ModelThreeArguments
(Value -> Parser ModelThreeArguments)
-> (Value -> Parser [ModelThreeArguments])
-> FromJSON ModelThreeArguments
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ModelThreeArguments]
$cparseJSONList :: Value -> Parser [ModelThreeArguments]
parseJSON :: Value -> Parser ModelThreeArguments
$cparseJSON :: Value -> Parser ModelThreeArguments
FromJSON, [ModelThreeArguments] -> Encoding
[ModelThreeArguments] -> Value
ModelThreeArguments -> Encoding
ModelThreeArguments -> Value
(ModelThreeArguments -> Value)
-> (ModelThreeArguments -> Encoding)
-> ([ModelThreeArguments] -> Value)
-> ([ModelThreeArguments] -> Encoding)
-> ToJSON ModelThreeArguments
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ModelThreeArguments] -> Encoding
$ctoEncodingList :: [ModelThreeArguments] -> Encoding
toJSONList :: [ModelThreeArguments] -> Value
$ctoJSONList :: [ModelThreeArguments] -> Value
toEncoding :: ModelThreeArguments -> Encoding
$ctoEncoding :: ModelThreeArguments -> Encoding
toJSON :: ModelThreeArguments -> Value
$ctoJSON :: ModelThreeArguments -> Value
ToJSON) via CustomJSON
        '[ TagSingleConstructors
         , SumTaggedObject "type" "arguments"
         , ConstructorTagModifier (StripPrefix "ModelThreeArguments", CamelToSnake)]
        ModelThreeArguments

instance Default ModelThreeArguments where
    def :: ModelThreeArguments
def = CostingInteger -> ModelThreeArguments
ModelThreeArgumentsConstantCost CostingInteger
0

runThreeArgumentModel
    :: ModelThreeArguments
    -> ExMemory
    -> ExMemory
    -> ExMemory
    -> CostingInteger
runThreeArgumentModel :: ModelThreeArguments
-> ExMemory -> ExMemory -> ExMemory -> CostingInteger
runThreeArgumentModel (ModelThreeArgumentsConstantCost CostingInteger
c) ExMemory
_ ExMemory
_ ExMemory
_ = CostingInteger
c
runThreeArgumentModel (ModelThreeArgumentsAddedSizes (ModelAddedSizes CostingInteger
intercept CostingInteger
slope)) (ExMemory CostingInteger
size1) (ExMemory CostingInteger
size2) (ExMemory CostingInteger
size3) =
    (CostingInteger
size1 CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
+ CostingInteger
size2 CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
+ CostingInteger
size3) CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
* CostingInteger
slope CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
+ CostingInteger
intercept
runThreeArgumentModel (ModelThreeArgumentsLinearInX (ModelLinearSize CostingInteger
intercept CostingInteger
slope)) (ExMemory CostingInteger
size1) ExMemory
_ ExMemory
_ =
    CostingInteger
size1 CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
* CostingInteger
slope CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
+ CostingInteger
intercept
runThreeArgumentModel (ModelThreeArgumentsLinearInY (ModelLinearSize CostingInteger
intercept CostingInteger
slope)) ExMemory
_ (ExMemory CostingInteger
size2) ExMemory
_ =
    CostingInteger
size2 CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
* CostingInteger
slope CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
+ CostingInteger
intercept
runThreeArgumentModel (ModelThreeArgumentsLinearInZ (ModelLinearSize CostingInteger
intercept CostingInteger
slope)) ExMemory
_ ExMemory
_ (ExMemory CostingInteger
size3) =
    CostingInteger
size3 CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
* CostingInteger
slope CostingInteger -> CostingInteger -> CostingInteger
forall a. Num a => a -> a -> a
+ CostingInteger
intercept

runCostingFunThreeArguments
    :: CostingFun ModelThreeArguments
    -> ExMemory
    -> ExMemory
    -> ExMemory
    -> ExBudget
runCostingFunThreeArguments :: CostingFun ModelThreeArguments
-> ExMemory -> ExMemory -> ExMemory -> ExBudget
runCostingFunThreeArguments (CostingFun ModelThreeArguments
cpu ModelThreeArguments
mem) ExMemory
mem1 ExMemory
mem2 ExMemory
mem3 =
    ExCPU -> ExMemory -> ExBudget
ExBudget (CostingInteger -> ExCPU
ExCPU    (CostingInteger -> ExCPU) -> CostingInteger -> ExCPU
forall a b. (a -> b) -> a -> b
$ ModelThreeArguments
-> ExMemory -> ExMemory -> ExMemory -> CostingInteger
runThreeArgumentModel ModelThreeArguments
cpu ExMemory
mem1 ExMemory
mem2 ExMemory
mem3)
             (CostingInteger -> ExMemory
ExMemory (CostingInteger -> ExMemory) -> CostingInteger -> ExMemory
forall a b. (a -> b) -> a -> b
$ ModelThreeArguments
-> ExMemory -> ExMemory -> ExMemory -> CostingInteger
runThreeArgumentModel ModelThreeArguments
mem ExMemory
mem1 ExMemory
mem2 ExMemory
mem3)


---------------- Four-argument costing functions ----------------

data ModelFourArguments =
      ModelFourArgumentsConstantCost CostingInteger
    deriving (Int -> ModelFourArguments -> ShowS
[ModelFourArguments] -> ShowS
ModelFourArguments -> String
(Int -> ModelFourArguments -> ShowS)
-> (ModelFourArguments -> String)
-> ([ModelFourArguments] -> ShowS)
-> Show ModelFourArguments
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModelFourArguments] -> ShowS
$cshowList :: [ModelFourArguments] -> ShowS
show :: ModelFourArguments -> String
$cshow :: ModelFourArguments -> String
showsPrec :: Int -> ModelFourArguments -> ShowS
$cshowsPrec :: Int -> ModelFourArguments -> ShowS
Show, ModelFourArguments -> ModelFourArguments -> Bool
(ModelFourArguments -> ModelFourArguments -> Bool)
-> (ModelFourArguments -> ModelFourArguments -> Bool)
-> Eq ModelFourArguments
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModelFourArguments -> ModelFourArguments -> Bool
$c/= :: ModelFourArguments -> ModelFourArguments -> Bool
== :: ModelFourArguments -> ModelFourArguments -> Bool
$c== :: ModelFourArguments -> ModelFourArguments -> Bool
Eq, (forall x. ModelFourArguments -> Rep ModelFourArguments x)
-> (forall x. Rep ModelFourArguments x -> ModelFourArguments)
-> Generic ModelFourArguments
forall x. Rep ModelFourArguments x -> ModelFourArguments
forall x. ModelFourArguments -> Rep ModelFourArguments x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModelFourArguments x -> ModelFourArguments
$cfrom :: forall x. ModelFourArguments -> Rep ModelFourArguments x
Generic, ModelFourArguments -> Q Exp
ModelFourArguments -> Q (TExp ModelFourArguments)
(ModelFourArguments -> Q Exp)
-> (ModelFourArguments -> Q (TExp ModelFourArguments))
-> Lift ModelFourArguments
forall t. (t -> Q Exp) -> (t -> Q (TExp t)) -> Lift t
liftTyped :: ModelFourArguments -> Q (TExp ModelFourArguments)
$cliftTyped :: ModelFourArguments -> Q (TExp ModelFourArguments)
lift :: ModelFourArguments -> Q Exp
$clift :: ModelFourArguments -> Q Exp
Lift, ModelFourArguments -> ()
(ModelFourArguments -> ()) -> NFData ModelFourArguments
forall a. (a -> ()) -> NFData a
rnf :: ModelFourArguments -> ()
$crnf :: ModelFourArguments -> ()
NFData)
    deriving (Value -> Parser [ModelFourArguments]
Value -> Parser ModelFourArguments
(Value -> Parser ModelFourArguments)
-> (Value -> Parser [ModelFourArguments])
-> FromJSON ModelFourArguments
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ModelFourArguments]
$cparseJSONList :: Value -> Parser [ModelFourArguments]
parseJSON :: Value -> Parser ModelFourArguments
$cparseJSON :: Value -> Parser ModelFourArguments
FromJSON, [ModelFourArguments] -> Encoding
[ModelFourArguments] -> Value
ModelFourArguments -> Encoding
ModelFourArguments -> Value
(ModelFourArguments -> Value)
-> (ModelFourArguments -> Encoding)
-> ([ModelFourArguments] -> Value)
-> ([ModelFourArguments] -> Encoding)
-> ToJSON ModelFourArguments
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ModelFourArguments] -> Encoding
$ctoEncodingList :: [ModelFourArguments] -> Encoding
toJSONList :: [ModelFourArguments] -> Value
$ctoJSONList :: [ModelFourArguments] -> Value
toEncoding :: ModelFourArguments -> Encoding
$ctoEncoding :: ModelFourArguments -> Encoding
toJSON :: ModelFourArguments -> Value
$ctoJSON :: ModelFourArguments -> Value
ToJSON) via CustomJSON
        '[ TagSingleConstructors
         , SumTaggedObject "type" "arguments"
         , ConstructorTagModifier (StripPrefix "ModelFourArguments", CamelToSnake)]
        ModelFourArguments

instance Default ModelFourArguments where
    def :: ModelFourArguments
def = CostingInteger -> ModelFourArguments
ModelFourArgumentsConstantCost CostingInteger
0

runFourArgumentModel
    :: ModelFourArguments
    -> ExMemory
    -> ExMemory
    -> ExMemory
    -> ExMemory
    -> CostingInteger
runFourArgumentModel :: ModelFourArguments
-> ExMemory -> ExMemory -> ExMemory -> ExMemory -> CostingInteger
runFourArgumentModel (ModelFourArgumentsConstantCost CostingInteger
c) ExMemory
_ ExMemory
_ ExMemory
_ ExMemory
_ = CostingInteger
c

runCostingFunFourArguments
    :: CostingFun ModelFourArguments
    -> ExMemory
    -> ExMemory
    -> ExMemory
    -> ExMemory
    -> ExBudget
runCostingFunFourArguments :: CostingFun ModelFourArguments
-> ExMemory -> ExMemory -> ExMemory -> ExMemory -> ExBudget
runCostingFunFourArguments (CostingFun ModelFourArguments
cpu ModelFourArguments
mem) ExMemory
mem1 ExMemory
mem2 ExMemory
mem3 ExMemory
mem4 =
    ExCPU -> ExMemory -> ExBudget
ExBudget (CostingInteger -> ExCPU
ExCPU    (CostingInteger -> ExCPU) -> CostingInteger -> ExCPU
forall a b. (a -> b) -> a -> b
$ ModelFourArguments
-> ExMemory -> ExMemory -> ExMemory -> ExMemory -> CostingInteger
runFourArgumentModel ModelFourArguments
cpu ExMemory
mem1 ExMemory
mem2 ExMemory
mem3 ExMemory
mem4)
             (CostingInteger -> ExMemory
ExMemory (CostingInteger -> ExMemory) -> CostingInteger -> ExMemory
forall a b. (a -> b) -> a -> b
$ ModelFourArguments
-> ExMemory -> ExMemory -> ExMemory -> ExMemory -> CostingInteger
runFourArgumentModel ModelFourArguments
mem ExMemory
mem1 ExMemory
mem2 ExMemory
mem3 ExMemory
mem4)


---------------- Five-argument costing functions ----------------

data ModelFiveArguments =
      ModelFiveArgumentsConstantCost CostingInteger
    deriving (Int -> ModelFiveArguments -> ShowS
[ModelFiveArguments] -> ShowS
ModelFiveArguments -> String
(Int -> ModelFiveArguments -> ShowS)
-> (ModelFiveArguments -> String)
-> ([ModelFiveArguments] -> ShowS)
-> Show ModelFiveArguments
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModelFiveArguments] -> ShowS
$cshowList :: [ModelFiveArguments] -> ShowS
show :: ModelFiveArguments -> String
$cshow :: ModelFiveArguments -> String
showsPrec :: Int -> ModelFiveArguments -> ShowS
$cshowsPrec :: Int -> ModelFiveArguments -> ShowS
Show, ModelFiveArguments -> ModelFiveArguments -> Bool
(ModelFiveArguments -> ModelFiveArguments -> Bool)
-> (ModelFiveArguments -> ModelFiveArguments -> Bool)
-> Eq ModelFiveArguments
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModelFiveArguments -> ModelFiveArguments -> Bool
$c/= :: ModelFiveArguments -> ModelFiveArguments -> Bool
== :: ModelFiveArguments -> ModelFiveArguments -> Bool
$c== :: ModelFiveArguments -> ModelFiveArguments -> Bool
Eq, (forall x. ModelFiveArguments -> Rep ModelFiveArguments x)
-> (forall x. Rep ModelFiveArguments x -> ModelFiveArguments)
-> Generic ModelFiveArguments
forall x. Rep ModelFiveArguments x -> ModelFiveArguments
forall x. ModelFiveArguments -> Rep ModelFiveArguments x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModelFiveArguments x -> ModelFiveArguments
$cfrom :: forall x. ModelFiveArguments -> Rep ModelFiveArguments x
Generic, ModelFiveArguments -> Q Exp
ModelFiveArguments -> Q (TExp ModelFiveArguments)
(ModelFiveArguments -> Q Exp)
-> (ModelFiveArguments -> Q (TExp ModelFiveArguments))
-> Lift ModelFiveArguments
forall t. (t -> Q Exp) -> (t -> Q (TExp t)) -> Lift t
liftTyped :: ModelFiveArguments -> Q (TExp ModelFiveArguments)
$cliftTyped :: ModelFiveArguments -> Q (TExp ModelFiveArguments)
lift :: ModelFiveArguments -> Q Exp
$clift :: ModelFiveArguments -> Q Exp
Lift, ModelFiveArguments -> ()
(ModelFiveArguments -> ()) -> NFData ModelFiveArguments
forall a. (a -> ()) -> NFData a
rnf :: ModelFiveArguments -> ()
$crnf :: ModelFiveArguments -> ()
NFData)
    deriving (Value -> Parser [ModelFiveArguments]
Value -> Parser ModelFiveArguments
(Value -> Parser ModelFiveArguments)
-> (Value -> Parser [ModelFiveArguments])
-> FromJSON ModelFiveArguments
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ModelFiveArguments]
$cparseJSONList :: Value -> Parser [ModelFiveArguments]
parseJSON :: Value -> Parser ModelFiveArguments
$cparseJSON :: Value -> Parser ModelFiveArguments
FromJSON, [ModelFiveArguments] -> Encoding
[ModelFiveArguments] -> Value
ModelFiveArguments -> Encoding
ModelFiveArguments -> Value
(ModelFiveArguments -> Value)
-> (ModelFiveArguments -> Encoding)
-> ([ModelFiveArguments] -> Value)
-> ([ModelFiveArguments] -> Encoding)
-> ToJSON ModelFiveArguments
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ModelFiveArguments] -> Encoding
$ctoEncodingList :: [ModelFiveArguments] -> Encoding
toJSONList :: [ModelFiveArguments] -> Value
$ctoJSONList :: [ModelFiveArguments] -> Value
toEncoding :: ModelFiveArguments -> Encoding
$ctoEncoding :: ModelFiveArguments -> Encoding
toJSON :: ModelFiveArguments -> Value
$ctoJSON :: ModelFiveArguments -> Value
ToJSON) via CustomJSON
        '[ TagSingleConstructors
         , SumTaggedObject "type" "arguments"
         , ConstructorTagModifier (StripPrefix "ModelFiveArguments", CamelToSnake)]
        ModelFiveArguments

instance Default ModelFiveArguments where
    def :: ModelFiveArguments
def = CostingInteger -> ModelFiveArguments
ModelFiveArgumentsConstantCost CostingInteger
0

runFiveArgumentModel
    :: ModelFiveArguments
    -> ExMemory
    -> ExMemory
    -> ExMemory
    -> ExMemory
    -> ExMemory
    -> CostingInteger
runFiveArgumentModel :: ModelFiveArguments
-> ExMemory
-> ExMemory
-> ExMemory
-> ExMemory
-> ExMemory
-> CostingInteger
runFiveArgumentModel (ModelFiveArgumentsConstantCost CostingInteger
c) ExMemory
_ ExMemory
_ ExMemory
_ ExMemory
_ ExMemory
_ = CostingInteger
c

runCostingFunFiveArguments
    :: CostingFun ModelFiveArguments
    -> ExMemory
    -> ExMemory
    -> ExMemory
    -> ExMemory
    -> ExMemory
    -> ExBudget
runCostingFunFiveArguments :: CostingFun ModelFiveArguments
-> ExMemory
-> ExMemory
-> ExMemory
-> ExMemory
-> ExMemory
-> ExBudget
runCostingFunFiveArguments (CostingFun ModelFiveArguments
cpu ModelFiveArguments
mem) ExMemory
mem1 ExMemory
mem2 ExMemory
mem3 ExMemory
mem4 ExMemory
mem5 =
    ExCPU -> ExMemory -> ExBudget
ExBudget (CostingInteger -> ExCPU
ExCPU    (CostingInteger -> ExCPU) -> CostingInteger -> ExCPU
forall a b. (a -> b) -> a -> b
$ ModelFiveArguments
-> ExMemory
-> ExMemory
-> ExMemory
-> ExMemory
-> ExMemory
-> CostingInteger
runFiveArgumentModel ModelFiveArguments
cpu ExMemory
mem1 ExMemory
mem2 ExMemory
mem3 ExMemory
mem4 ExMemory
mem5)
             (CostingInteger -> ExMemory
ExMemory (CostingInteger -> ExMemory) -> CostingInteger -> ExMemory
forall a b. (a -> b) -> a -> b
$ ModelFiveArguments
-> ExMemory
-> ExMemory
-> ExMemory
-> ExMemory
-> ExMemory
-> CostingInteger
runFiveArgumentModel ModelFiveArguments
mem ExMemory
mem1 ExMemory
mem2 ExMemory
mem3 ExMemory
mem4 ExMemory
mem5)


---------------- Six-argument costing functions ----------------

data ModelSixArguments =
      ModelSixArgumentsConstantCost CostingInteger
    deriving (Int -> ModelSixArguments -> ShowS
[ModelSixArguments] -> ShowS
ModelSixArguments -> String
(Int -> ModelSixArguments -> ShowS)
-> (ModelSixArguments -> String)
-> ([ModelSixArguments] -> ShowS)
-> Show ModelSixArguments
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModelSixArguments] -> ShowS
$cshowList :: [ModelSixArguments] -> ShowS
show :: ModelSixArguments -> String
$cshow :: ModelSixArguments -> String
showsPrec :: Int -> ModelSixArguments -> ShowS
$cshowsPrec :: Int -> ModelSixArguments -> ShowS
Show, ModelSixArguments -> ModelSixArguments -> Bool
(ModelSixArguments -> ModelSixArguments -> Bool)
-> (ModelSixArguments -> ModelSixArguments -> Bool)
-> Eq ModelSixArguments
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModelSixArguments -> ModelSixArguments -> Bool
$c/= :: ModelSixArguments -> ModelSixArguments -> Bool
== :: ModelSixArguments -> ModelSixArguments -> Bool
$c== :: ModelSixArguments -> ModelSixArguments -> Bool
Eq, (forall x. ModelSixArguments -> Rep ModelSixArguments x)
-> (forall x. Rep ModelSixArguments x -> ModelSixArguments)
-> Generic ModelSixArguments
forall x. Rep ModelSixArguments x -> ModelSixArguments
forall x. ModelSixArguments -> Rep ModelSixArguments x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModelSixArguments x -> ModelSixArguments
$cfrom :: forall x. ModelSixArguments -> Rep ModelSixArguments x
Generic, ModelSixArguments -> Q Exp
ModelSixArguments -> Q (TExp ModelSixArguments)
(ModelSixArguments -> Q Exp)
-> (ModelSixArguments -> Q (TExp ModelSixArguments))
-> Lift ModelSixArguments
forall t. (t -> Q Exp) -> (t -> Q (TExp t)) -> Lift t
liftTyped :: ModelSixArguments -> Q (TExp ModelSixArguments)
$cliftTyped :: ModelSixArguments -> Q (TExp ModelSixArguments)
lift :: ModelSixArguments -> Q Exp
$clift :: ModelSixArguments -> Q Exp
Lift, ModelSixArguments -> ()
(ModelSixArguments -> ()) -> NFData ModelSixArguments
forall a. (a -> ()) -> NFData a
rnf :: ModelSixArguments -> ()
$crnf :: ModelSixArguments -> ()
NFData)
    deriving (Value -> Parser [ModelSixArguments]
Value -> Parser ModelSixArguments
(Value -> Parser ModelSixArguments)
-> (Value -> Parser [ModelSixArguments])
-> FromJSON ModelSixArguments
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ModelSixArguments]
$cparseJSONList :: Value -> Parser [ModelSixArguments]
parseJSON :: Value -> Parser ModelSixArguments
$cparseJSON :: Value -> Parser ModelSixArguments
FromJSON, [ModelSixArguments] -> Encoding
[ModelSixArguments] -> Value
ModelSixArguments -> Encoding
ModelSixArguments -> Value
(ModelSixArguments -> Value)
-> (ModelSixArguments -> Encoding)
-> ([ModelSixArguments] -> Value)
-> ([ModelSixArguments] -> Encoding)
-> ToJSON ModelSixArguments
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ModelSixArguments] -> Encoding
$ctoEncodingList :: [ModelSixArguments] -> Encoding
toJSONList :: [ModelSixArguments] -> Value
$ctoJSONList :: [ModelSixArguments] -> Value
toEncoding :: ModelSixArguments -> Encoding
$ctoEncoding :: ModelSixArguments -> Encoding
toJSON :: ModelSixArguments -> Value
$ctoJSON :: ModelSixArguments -> Value
ToJSON) via CustomJSON
        '[ TagSingleConstructors
         , SumTaggedObject "type" "arguments"
         , ConstructorTagModifier (StripPrefix "ModelSixArguments", CamelToSnake)]
        ModelSixArguments

instance Default ModelSixArguments where
    def :: ModelSixArguments
def = CostingInteger -> ModelSixArguments
ModelSixArgumentsConstantCost CostingInteger
0

runSixArgumentModel
    :: ModelSixArguments
    -> ExMemory
    -> ExMemory
    -> ExMemory
    -> ExMemory
    -> ExMemory
    -> ExMemory
    -> CostingInteger
runSixArgumentModel :: ModelSixArguments
-> ExMemory
-> ExMemory
-> ExMemory
-> ExMemory
-> ExMemory
-> ExMemory
-> CostingInteger
runSixArgumentModel (ModelSixArgumentsConstantCost CostingInteger
c) ExMemory
_ ExMemory
_ ExMemory
_ ExMemory
_ ExMemory
_ ExMemory
_ = CostingInteger
c

runCostingFunSixArguments
    :: CostingFun ModelSixArguments
    -> ExMemory
    -> ExMemory
    -> ExMemory
    -> ExMemory
    -> ExMemory
    -> ExMemory
    -> ExBudget
runCostingFunSixArguments :: CostingFun ModelSixArguments
-> ExMemory
-> ExMemory
-> ExMemory
-> ExMemory
-> ExMemory
-> ExMemory
-> ExBudget
runCostingFunSixArguments (CostingFun ModelSixArguments
cpu ModelSixArguments
mem) ExMemory
mem1 ExMemory
mem2 ExMemory
mem3 ExMemory
mem4 ExMemory
mem5 ExMemory
mem6 =
    ExCPU -> ExMemory -> ExBudget
ExBudget (CostingInteger -> ExCPU
ExCPU    (CostingInteger -> ExCPU) -> CostingInteger -> ExCPU
forall a b. (a -> b) -> a -> b
$ ModelSixArguments
-> ExMemory
-> ExMemory
-> ExMemory
-> ExMemory
-> ExMemory
-> ExMemory
-> CostingInteger
runSixArgumentModel ModelSixArguments
cpu ExMemory
mem1 ExMemory
mem2 ExMemory
mem3 ExMemory
mem4 ExMemory
mem5 ExMemory
mem6)
             (CostingInteger -> ExMemory
ExMemory (CostingInteger -> ExMemory) -> CostingInteger -> ExMemory
forall a b. (a -> b) -> a -> b
$ ModelSixArguments
-> ExMemory
-> ExMemory
-> ExMemory
-> ExMemory
-> ExMemory
-> ExMemory
-> CostingInteger
runSixArgumentModel ModelSixArguments
mem ExMemory
mem1 ExMemory
mem2 ExMemory
mem3 ExMemory
mem4 ExMemory
mem5 ExMemory
mem6)