Skip to content

Commit

Permalink
remove most strictness changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcardon committed Jul 6, 2023
1 parent 9ddffb3 commit 5e17590
Show file tree
Hide file tree
Showing 26 changed files with 182 additions and 185 deletions.
12 changes: 6 additions & 6 deletions src-ghc/Pact/ApiReq.hs
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ instance Arbitrary ApiSigner where
-- ApiPublicMeta

data ApiPublicMeta = ApiPublicMeta
{ _apmChainId :: !(Maybe ChainId)
, _apmSender :: !(Maybe Text)
, _apmGasLimit :: !(Maybe GasLimit)
, _apmGasPrice :: !(Maybe GasPrice)
, _apmTTL :: !(Maybe TTLSeconds)
, _apmCreationTime :: !(Maybe TxCreationTime)
{ _apmChainId :: Maybe ChainId
, _apmSender :: Maybe Text
, _apmGasLimit :: Maybe GasLimit
, _apmGasPrice :: Maybe GasPrice
, _apmTTL :: Maybe TTLSeconds
, _apmCreationTime :: Maybe TxCreationTime
} deriving (Eq, Show, Generic)

instance FromJSON ApiPublicMeta where
Expand Down
14 changes: 7 additions & 7 deletions src-ghc/Pact/GasModel/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,13 @@ createPactExpr f (PactExpression arg abridged) =


data MockPactType =
MockObject !(HM.HashMap T.Text Integer)
| MockBinding !(HM.HashMap T.Text Integer)
| MockList ![MockPactType]
| MockBool !Bool
| MockInt !Integer
| MockString !T.Text
| MockExpr !T.Text
MockObject (HM.HashMap T.Text Integer)
| MockBinding (HM.HashMap T.Text Integer)
| MockList [MockPactType]
| MockBool Bool
| MockInt Integer
| MockString T.Text
| MockExpr T.Text
deriving (Show)

toText :: MockPactType -> T.Text
Expand Down
32 changes: 16 additions & 16 deletions src-ghc/Pact/Persist/SQLite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,24 @@ import qualified Pact.JSON.Encode as J


data TableStmts = TableStmts
{ sInsertReplace :: !Statement
, sInsert :: !Statement
, sReplace :: !Statement
, sRead :: !Statement
{ sInsertReplace :: Statement
, sInsert :: Statement
, sReplace :: Statement
, sRead :: Statement
}

data TxStmts = TxStmts
{ tBegin :: !Statement
, tCommit :: !Statement
, tRollback :: !Statement
{ tBegin :: Statement
, tCommit :: Statement
, tRollback :: Statement
}

data SQLite = SQLite
{ conn :: !Database
, config :: !SQLiteConfig
, logger :: !Logger
, tableStmts :: !(M.Map Utf8 TableStmts)
, txStmts :: !TxStmts
{ conn :: Database
, config :: SQLiteConfig
, logger :: Logger
, tableStmts :: (M.Map Utf8 TableStmts)
, txStmts :: TxStmts
}

toUtf8 :: Text -> Utf8
Expand Down Expand Up @@ -89,10 +89,10 @@ persister = Persister {
}

data KeyTys k = KeyTys {
textTy :: !Utf8,
inFun :: !(k -> SType),
outTy :: !RType,
outFun :: !(SType -> IO k)
textTy :: Utf8,
inFun :: k -> SType,
outTy :: RType,
outFun :: SType -> IO k
}

decodeText :: SType -> IO DataKey
Expand Down
6 changes: 3 additions & 3 deletions src-ghc/Pact/Types/Crypto.hs
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ instance ConvertBS (ECDSA.Signature) where

-- | Specialized KeyPair datatype for schemes
data KeyPair a = KeyPair
{ _kpScheme :: !a
, _kpPublicKey :: !(PublicKey a)
, _kpPrivateKey :: !(PrivateKey a)
{ _kpScheme :: a
, _kpPublicKey :: PublicKey a
, _kpPrivateKey :: PrivateKey a
}

instance Scheme a => Show (KeyPair a) where
Expand Down
6 changes: 3 additions & 3 deletions src-ghc/Pact/Types/SQLite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ instance J.Encode Pragma where
build (Pragma s) = J.string s

data SQLiteConfig = SQLiteConfig
{ _dbFile :: !FilePath
, _pragmas :: ![Pragma]
{ _dbFile :: FilePath
, _pragmas :: [Pragma]
} deriving (Eq,Show,Generic)
instance FromJSON SQLiteConfig
makeLenses ''SQLiteConfig
Expand All @@ -76,7 +76,7 @@ instance Arbitrary SQLiteConfig where
arbitrary = SQLiteConfig <$> arbitrary <*> arbitrary

-- | Statement input types
data SType = SInt !Int64 | SDouble !Double | SText !Utf8 | SBlob !BS.ByteString deriving (Eq,Show)
data SType = SInt Int64 | SDouble Double | SText Utf8 | SBlob BS.ByteString deriving (Eq,Show)
-- | Result types
data RType = RInt | RDouble | RText | RBlob deriving (Eq,Show)

Expand Down
32 changes: 16 additions & 16 deletions src-ghc/Pact/Types/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,26 +73,26 @@ userSigsToPactKeySet = S.fromList . fmap userSigToPactPubKey


data CommandConfig = CommandConfig {
_ccSqlite :: !(Maybe SQLiteConfig)
, _ccEntity :: !(Maybe EntityName)
, _ccGasLimit :: !(Maybe Int)
, _ccGasRate :: !(Maybe Int)
_ccSqlite :: Maybe SQLiteConfig
, _ccEntity :: Maybe EntityName
, _ccGasLimit :: Maybe Int
, _ccGasRate :: Maybe Int
, _ccExecutionConfig :: !ExecutionConfig
}
$(makeLenses ''CommandConfig)



data CommandEnv p = CommandEnv {
_ceEntity :: !(Maybe EntityName)
, _ceMode :: !ExecutionMode
, _ceDbEnv :: !(PactDbEnv p)
, _ceLogger :: !Logger
, _ceGasEnv :: !GasEnv
_ceEntity :: Maybe EntityName
, _ceMode :: ExecutionMode
, _ceDbEnv :: PactDbEnv p
, _ceLogger :: Logger
, _ceGasEnv :: GasEnv
, _cePublicData :: !PublicData
, _ceSPVSupport :: !SPVSupport
, _ceNetworkId :: !(Maybe NetworkId)
, _ceExecutionConfig :: !ExecutionConfig
, _ceNetworkId :: Maybe NetworkId
, _ceExecutionConfig :: ExecutionConfig
}
$(makeLenses ''CommandEnv)

Expand Down Expand Up @@ -139,8 +139,8 @@ newtype PossiblyIncompleteResults = PossiblyIncompleteResults
} deriving (Show, Eq)

data ListenerResult =
ListenerResult !(CommandResult Hash) |
GCed !String
ListenerResult (CommandResult Hash) |
GCed String
deriving (Show, Eq)

data History =
Expand All @@ -156,8 +156,8 @@ data History =


data Inbound =
TxCmds { iCmds :: ![Command ByteString] } |
LocalCmd { iCmd :: !(Command ByteString),
iLocalResult :: !(MVar (CommandResult Hash))
TxCmds { iCmds :: [Command ByteString] } |
LocalCmd { iCmd :: Command ByteString,
iLocalResult :: MVar (CommandResult Hash)
}
deriving (Eq)
2 changes: 0 additions & 2 deletions src-tool/Pact/Analyze/Alloc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,3 @@ instance MonadAlloc Alloc where
singForAll name ty = Alloc $ withSymVal ty $ sansProv <$> SBV.sbvForall name
singExists name ty = Alloc $ withSymVal ty $ sansProv <$> SBV.sbvExists name
singFree name ty = Alloc $ withSymVal ty $ sansProv <$> SBV.free name
-- singForAll name ty = Alloc $ withSymVal ty $ sansProv <$> error "sbvForall removed in 10.0" name
-- singExists name ty = Alloc $ withSymVal ty $ sansProv <$> error "sbvExists removed in 10.0" name
12 changes: 6 additions & 6 deletions src/Crypto/Hash/Blake2Native.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ type V = Vector

-- | state context
data Blake2Ctx w = Blake2Ctx
{ _b :: !ByteString -- 128 input buffer
, _h :: !(V w) -- 8 chained state
, _t0 :: !w -- total number of bytes 0
, _t1 :: !w -- 1
, _c :: !Int -- pointer for b[]
, _outlen :: !Int -- digest size
{ _b :: ByteString -- 128 input buffer
, _h :: V w -- 8 chained state
, _t0 :: w -- total number of bytes 0
, _t1 :: w -- 1
, _c :: Int -- pointer for b[]
, _outlen :: Int -- digest size
} deriving (Eq)
instance (Show w) => Show (Blake2Ctx w) where
show (Blake2Ctx b h t0 t1 c outlen) =
Expand Down
2 changes: 1 addition & 1 deletion src/Pact/Analyze/Remote/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import Pact.Types.Term (ModuleDef, ModuleName, Name)
import Test.QuickCheck

data Request
= Request ![ModuleDef Name] !ModuleName -- ^ verify one of the modules, by name
= Request [ModuleDef Name] ModuleName -- ^ verify one of the modules, by name
deriving (Eq, Show, Generic)

instance A.FromJSON Request where
Expand Down
16 changes: 8 additions & 8 deletions src/Pact/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,20 @@ import Pact.Types.Util


data ModuleState = ModuleState
{ _msName :: !ModuleName
, _msHash :: !ModuleHash
, _msBlessed :: ![ModuleHash]
, _msImplements :: ![ModuleName]
, _msImports :: ![Use]
{ _msName :: ModuleName
, _msHash :: ModuleHash
, _msBlessed :: [ModuleHash]
, _msImplements :: [ModuleName]
, _msImports :: [Use]
}
makeLenses ''ModuleState

initModuleState :: ModuleName -> ModuleHash -> ModuleState
initModuleState n h = ModuleState n h def def def

data CompileState = CompileState
{ _csFresh :: !Int
, _csModule :: !(Maybe ModuleState)
{ _csFresh :: Int
, _csModule :: Maybe ModuleState
}
makeLenses ''CompileState

Expand Down Expand Up @@ -390,7 +390,7 @@ data ModelAllowed
= ModelAllowed
| ModelNotAllowed

data AtPair = DocPair !Text | ModelPair ![Exp Info] deriving (Eq,Ord)
data AtPair = DocPair Text | ModelPair [Exp Info] deriving (Eq,Ord)

modelOnly :: Compile Meta
modelOnly = do
Expand Down
15 changes: 7 additions & 8 deletions src/Pact/Gas.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ module Pact.Gas
, putGas)
where

import Control.Monad
import Control.Monad.State.Strict
import Data.Text
import Data.IORef
Expand All @@ -31,16 +30,16 @@ computeGas i args = do
GasEnv {..} <- view eeGasEnv
g0 <- getGas
let
(!info,!name) = either id (_faInfo &&& _faName) i
!g1 = runGasModel _geGasModel name args
let !gUsed = g0 + g1
modify' $ over evalLogGas $ (<$!>) ((:) (msg name gUsed, g1))
(info,name) = either id (_faInfo &&& _faName) i
g1 = runGasModel _geGasModel name args
let gUsed = g0 + g1
evalLogGas %= fmap ((msg name gUsed, g1):)
putGas gUsed
if gUsed > fromIntegral _geGasLimit then
throwErr GasError info $ "Gas limit (" <> pretty _geGasLimit <> ") exceeded: " <> pretty gUsed
else return gUsed
where
msg name used = renderCompactText' $! pretty name <> ":" <> pretty args <> ":currTotalGas=" <> pretty used
msg name used = renderCompactText' (pretty name <> ":" <> pretty args <> ":currTotalGas=" <> pretty used)
{-# INLINABLE computeGas #-}

-- | Performs gas calculation for incremental computations with some caveats:
Expand All @@ -59,7 +58,7 @@ computeGasNoLog commit info name args = do

putGas :: Gas -> Eval e ()
putGas !g = do
!gasRef <- view eeGas
gasRef <- view eeGas
liftIO (writeIORef gasRef g)

getGas :: Eval e Gas
Expand All @@ -76,7 +75,7 @@ computeGasCommit info name args = do
g0 <- getGas
let !g1 = runGasModel _geGasModel name args
!gUsed = g0 + g1
evalLogGas %= (<$!>) ((renderCompactText' $! pretty name <> ":" <> pretty args <> ":currTotalGas=" <> pretty gUsed,g1):)
evalLogGas %= fmap ((renderCompactText' (pretty name <> ":" <> pretty args <> ":currTotalGas=" <> pretty gUsed),g1):)
putGas gUsed
if gUsed > fromIntegral _geGasLimit then
throwErr GasError info $ "Gas limit (" <> pretty _geGasLimit <> ") exceeded: " <> pretty gUsed
Expand Down
30 changes: 15 additions & 15 deletions src/Pact/Gas/Table.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ import Pact.Types.Term
-- able to find instances where GReduced was in present use, so I've removed it for now.

data GasCostConfig = GasCostConfig
{ _gasCostConfig_primTable :: !(Map Text Gas)
, _gasCostConfig_selectColumnCost :: !Gas -- up-front cost per column in a select operation
, _gasCostConfig_readColumnCost :: !Gas -- cost per column to read a row
, _gasCostConfig_sortFactor :: !Gas
, _gasCostConfig_distinctFactor :: !Gas
, _gasCostConfig_concatenationFactor :: !Gas
, _gasCostConfig_moduleCost :: !Gas
, _gasCostConfig_moduleMemberCost :: !Gas
, _gasCostConfig_useModuleCost :: !Gas
, _gasCostConfig_interfaceCost :: !Gas
, _gasCostConfig_writeBytesCost :: !Gas -- cost per bytes to write to database
, _gasCostConfig_functionApplicationCost :: !Gas
, _gasCostConfig_defPactCost :: !Gas
, _gasCostConfig_foldDBCost :: !Gas
, _gasCostConfig_principalCost :: !Gas
{ _gasCostConfig_primTable :: Map Text Gas
, _gasCostConfig_selectColumnCost :: Gas -- up-front cost per column in a select operation
, _gasCostConfig_readColumnCost :: Gas -- cost per column to read a row
, _gasCostConfig_sortFactor :: Gas
, _gasCostConfig_distinctFactor :: Gas
, _gasCostConfig_concatenationFactor :: Gas
, _gasCostConfig_moduleCost :: Gas
, _gasCostConfig_moduleMemberCost :: Gas
, _gasCostConfig_useModuleCost :: Gas
, _gasCostConfig_interfaceCost :: Gas
, _gasCostConfig_writeBytesCost :: Gas -- cost per bytes to write to database
, _gasCostConfig_functionApplicationCost :: Gas
, _gasCostConfig_defPactCost :: Gas
, _gasCostConfig_foldDBCost :: Gas
, _gasCostConfig_principalCost :: Gas
}

defaultGasConfig :: GasCostConfig
Expand Down
22 changes: 11 additions & 11 deletions src/Pact/Persist.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ conjToOp c = fromString $ case c of
{-# INLINE conjToOp #-}

data KeyQuery k =
KQKey { kqCmp :: !KeyCmp, kqKey :: !k } |
KQConj { kqL :: !(KeyQuery k), kqConj :: !KeyConj, kqR :: !(KeyQuery k) }
KQKey { kqCmp :: KeyCmp, kqKey :: k } |
KQConj { kqL :: KeyQuery k, kqConj :: KeyConj, kqR :: KeyQuery k }
deriving (Eq,Show)

-- | Convenience for infix usage.
Expand Down Expand Up @@ -120,23 +120,23 @@ instance PactDbKey TxKey
instance PactDbKey DataKey

data Persister s = Persister {
createTable :: !(forall k . PactDbKey k => Table k -> Persist s ())
createTable :: forall k . PactDbKey k => Table k -> Persist s ()
,
beginTx :: !(ExecutionMode -> Persist s ())
beginTx :: ExecutionMode -> Persist s ()
,
commitTx :: !(Persist s ())
commitTx :: Persist s ()
,
rollbackTx :: !(Persist s ())
rollbackTx :: Persist s ()
,
queryKeys :: !(forall k . PactDbKey k => Table k -> Maybe (KeyQuery k) -> Persist s [k])
queryKeys :: forall k . PactDbKey k => Table k -> Maybe (KeyQuery k) -> Persist s [k]
,
query :: !(forall k v . (PactDbKey k, FromJSON v, Typeable v) => Table k -> Maybe (KeyQuery k) -> Persist s [(k,v)])
query :: forall k v . (PactDbKey k, FromJSON v, Typeable v) => Table k -> Maybe (KeyQuery k) -> Persist s [(k,v)]
,
readValue :: !(forall k v . (PactDbKey k, FromJSON v, Typeable v) => Table k -> k -> Persist s (Maybe v))
readValue :: forall k v . (PactDbKey k, FromJSON v, Typeable v) => Table k -> k -> Persist s (Maybe v)
,
writeValue :: !(forall k . (PactDbKey k) => Table k -> WriteType -> k -> B.ByteString -> Persist s ())
writeValue :: forall k . (PactDbKey k) => Table k -> WriteType -> k -> B.ByteString -> Persist s ()
,
refreshConn :: !(Persist s ())
refreshConn :: Persist s ()
}

_compileQry1 :: (String,[Int])
Expand Down
2 changes: 1 addition & 1 deletion src/Pact/Repl/Lib.hs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ setmsg i as = case as of
[TObject (Object om _ _ _) _] -> go (toLegacyJsonViaEncode (fmap toPactValueLenient om))
[a] -> go (toLegacyJsonViaEncode a)
_ -> argsError i as
where go (v :: LegacyValue) = setenv eeMsgBody v >> return (tStr "Setting transaction data")
where go v = setenv eeMsgBody v >> return (tStr "Setting transaction data")

continuePact :: RNativeFun LibState
continuePact i as = case as of
Expand Down
Loading

0 comments on commit 5e17590

Please sign in to comment.