diff --git a/src/Pact/Bench.hs b/src/Pact/Bench.hs index a02bf74ea..79c908b3a 100644 --- a/src/Pact/Bench.hs +++ b/src/Pact/Bench.hs @@ -285,7 +285,7 @@ main :: IO () main = do -- uncomment below to see if "-N" is working, important for file perf log -- print =<< getNumCapabilities - !fperf <- if doPerf /= None then mkFilePerf "pact-bench-perf" else def + !fperf <- if doPerf /= None then mkFilePerf "pact-bench-perf" else pure def let !dbPerf = if doPerf == Db || doPerf == All then fperf else def !interpPerf = if doPerf == Interp || doPerf == All then fperf else def !pub <- eitherDie "pub" $ parseB16TextOnly pk diff --git a/src/Pact/Runtime/Utils.hs b/src/Pact/Runtime/Utils.hs index 759efc5d7..66ac83579 100644 --- a/src/Pact/Runtime/Utils.hs +++ b/src/Pact/Runtime/Utils.hs @@ -146,7 +146,7 @@ stripTermInfo = stripTerm' stripNameInfo stripArgInfo f (Arg an argtyp _info) = Arg an (stripTypeInfo f argtyp) def stripMetaInfo (Meta docs model) = - Meta docs (fmap def <$> model) + Meta docs (fmap (const def) <$> model) stripAppInfo f (App af args _info) = App (stripTerm' f af) (stripTerm' f <$> args) def stripStepInfo f = \case diff --git a/src/Pact/Types/Capability.hs b/src/Pact/Types/Capability.hs index 82b751f46..42f8d24c9 100644 --- a/src/Pact/Types/Capability.hs +++ b/src/Pact/Types/Capability.hs @@ -25,7 +25,7 @@ module Pact.Types.Capability , UserManagedCap(..), umcManagedValue, umcManageParamIndex, umcManageParamName, umcMgrFun , AutoManagedCap(..), amcActive , decomposeManaged, decomposeManaged', matchManaged - , Capabilities(..), capStack, capManaged, capModuleAdmin, capAutonomous + , Capabilities(..), capStack, capManaged, capModuleAdmin, capAutonomous, emptyCapabilities , CapScope(..) , CapSlot(..), csCap, csComposed, csScope ) where @@ -191,9 +191,12 @@ data Capabilities = Capabilities } deriving (Eq,Show,Generic) -instance Default Capabilities where def = Capabilities [] mempty mempty mempty +instance Default Capabilities where def = emptyCapabilities instance NFData Capabilities +emptyCapabilities :: Capabilities +emptyCapabilities = Capabilities mempty mempty mempty mempty + makeLenses ''ManagedCapability makeLenses ''Capabilities makeLenses ''CapSlot diff --git a/src/Pact/Types/ChainMeta.hs b/src/Pact/Types/ChainMeta.hs index 9c657b3a0..8d65a1216 100644 --- a/src/Pact/Types/ChainMeta.hs +++ b/src/Pact/Types/ChainMeta.hs @@ -27,6 +27,8 @@ module Pact.Types.ChainMeta , pmAddress, pmChainId, pmSender, pmGasLimit, pmGasPrice, pmTTL, pmCreationTime , pdPublicMeta, pdBlockHeight, pdBlockTime, pdPrevBlockHash , getCurrentCreationTime + , noPublicMeta + , noPublicData ) where @@ -149,7 +151,10 @@ data PublicMeta = PublicMeta } deriving (Eq, Show, Generic) makeLenses ''PublicMeta -instance Default PublicMeta where def = PublicMeta "" "" 0 0 0 0 +instance Default PublicMeta where def = noPublicMeta + +noPublicMeta :: PublicMeta +noPublicMeta = PublicMeta "" mempty 0 0 0 0 instance Arbitrary PublicMeta where arbitrary = PublicMeta @@ -224,7 +229,10 @@ instance J.Encode PublicData where {-# INLINABLE build #-} instance FromJSON PublicData where parseJSON = lensyParseJSON 3 -instance Default PublicData where def = PublicData def def def def +instance Default PublicData where def = noPublicData + +noPublicData :: PublicData +noPublicData = PublicData noPublicMeta 0 0 mempty instance Arbitrary PublicData where arbitrary = PublicData diff --git a/src/Pact/Types/Info.hs b/src/Pact/Types/Info.hs index 97b43d808..2ea79fca3 100644 --- a/src/Pact/Types/Info.hs +++ b/src/Pact/Types/Info.hs @@ -20,12 +20,14 @@ module Pact.Types.Info ( Parsed(..), + noParsed, Code(..), Info(..), mkInfo, renderInfo, renderParsed, - HasInfo(..) + HasInfo(..), + noInfo ) where @@ -81,9 +83,11 @@ instance Arbitrary Parsed where -- The parser always assumes that the last to numbers are zero , Directed <$> genFilename <*> genPositiveInt64 <*> genPositiveInt64 <*> pure 0 <*> pure 0 ] instance NFData Parsed -instance Default Parsed where def = Parsed mempty 0 +instance Default Parsed where def = noParsed instance Pretty Parsed where pretty = pretty . _pDelta +noParsed :: Parsed +noParsed = Parsed mempty 0 newtype Code = Code { _unCode :: Text } deriving (Eq,Ord,Generic) @@ -110,7 +114,10 @@ instance Show Info where show (Info Nothing) = "" show (Info (Just (r,_d))) = renderCompactString r -instance Default Info where def = Info Nothing +instance Default Info where def = noInfo + +noInfo :: Info +noInfo = Info Nothing -- | Charge zero for Info to avoid quadratic blowup (i.e. for modules) instance SizeOf Info where diff --git a/src/Pact/Types/Runtime.hs b/src/Pact/Types/Runtime.hs index 90f3f172e..dd024768e 100644 --- a/src/Pact/Types/Runtime.hs +++ b/src/Pact/Types/Runtime.hs @@ -35,8 +35,8 @@ module Pact.Types.Runtime eeAdvice, eeWarnings, eeSigCapBypass, toPactId, Purity(..), - RefState(..),rsLoaded,rsLoadedModules,rsNamespace,rsQualifiedDeps, - EvalState(..),evalRefs,evalCallStack,evalPactExec, + RefState(..),rsLoaded,rsLoadedModules,rsNamespace,rsQualifiedDeps,emptyRefState, + EvalState(..),evalRefs,evalCallStack,evalPactExec,emptyEvalState, evalCapabilities,evalLogGas,evalEvents,evalUserCapabilitiesBeingEvaluated, Eval(..),runEval,runEval',catchesPactError, call,method, @@ -45,7 +45,7 @@ module Pact.Types.Runtime NamespacePolicy(..), permissiveNamespacePolicy, ExecutionConfig(..),ExecutionFlag(..),ecFlags,isExecutionFlagSet,flagRep,flagReps, - mkExecutionConfig, + mkExecutionConfig,emptyExecutionConfig, ifExecutionFlagSet,ifExecutionFlagSet', whenExecutionFlagSet, unlessExecutionFlagSet, emitPactWarning, @@ -242,10 +242,13 @@ newtype ExecutionConfig = ExecutionConfig deriving (FromJSON) makeLenses ''ExecutionConfig -instance Default ExecutionConfig where def = ExecutionConfig def +instance Default ExecutionConfig where def = emptyExecutionConfig instance Pretty ExecutionConfig where pretty = pretty . S.toList . _ecFlags +emptyExecutionConfig :: ExecutionConfig +emptyExecutionConfig = ExecutionConfig mempty + instance Arbitrary ExecutionConfig where arbitrary = ExecutionConfig <$> arbitrary @@ -323,7 +326,10 @@ data RefState = RefState { makeLenses ''RefState instance NFData RefState -instance Default RefState where def = RefState HM.empty HM.empty Nothing HM.empty +instance Default RefState where def = emptyRefState + +emptyRefState :: RefState +emptyRefState = RefState mempty mempty Nothing mempty data PactEvent = PactEvent { _eventName :: !Text @@ -373,7 +379,10 @@ data EvalState = EvalState { } deriving (Show, Generic) makeLenses ''EvalState instance NFData EvalState -instance Default EvalState where def = EvalState def def def def def def def +instance Default EvalState where def = emptyEvalState + +emptyEvalState :: EvalState +emptyEvalState = EvalState emptyRefState mempty Nothing emptyCapabilities mempty mempty mempty -- | Interpreter monad, parameterized over back-end MVar state type. newtype Eval e a =