Skip to content

Commit

Permalink
Merge pull request #1165 from GaloisInc/expose-utils
Browse files Browse the repository at this point in the history
Expose `modPathSplit` and `defaultSolverConfig` for downstream use
  • Loading branch information
robdockins authored Apr 19, 2021
2 parents 3474960 + a279e78 commit 51e5d91
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
11 changes: 1 addition & 10 deletions cryptol-remote-api/src/CryptolServer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Cryptol.ModuleSystem.Env
initialModuleEnv, meSearchPath, ModulePath(..))
import Cryptol.ModuleSystem.Fingerprint ( fingerprintFile )
import Cryptol.Parser.AST (ModName)
import Cryptol.TypeCheck( SolverConfig(..) )
import Cryptol.TypeCheck( defaultSolverConfig )
import qualified Cryptol.TypeCheck.Solver.SMT as SMT

import qualified Argo
Expand Down Expand Up @@ -135,15 +135,6 @@ initialState =
s <- SMT.startSolver (defaultSolverConfig (meSearchPath modEnv))
pure (ServerState Nothing modEnv s)

defaultSolverConfig :: [FilePath] -> SolverConfig
defaultSolverConfig searchPath =
SolverConfig
{ solverPath = "z3"
, solverArgs = [ "-smt2", "-in" ]
, solverVerbose = 0
, solverPreludePath = searchPath
}

extendSearchPath :: [FilePath] -> ServerState -> ServerState
extendSearchPath paths =
over moduleEnv $ \me -> me { meSearchPath = nubOrd $ paths ++ meSearchPath me }
Expand Down
8 changes: 1 addition & 7 deletions src/Cryptol/REPL/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,7 @@ defaultRW :: Bool -> Bool -> Logger -> IO RW
defaultRW isBatch callStacks l = do
env <- M.initialModuleEnv
let searchPath = M.meSearchPath env
let solverConfig =
T.SolverConfig
{ T.solverPath = "z3"
, T.solverArgs = [ "-smt2", "-in" ]
, T.solverVerbose = 0
, T.solverPreludePath = searchPath
}
let solverConfig = T.defaultSolverConfig searchPath
return RW
{ eLoadedMod = Nothing
, eEditFile = Nothing
Expand Down
3 changes: 2 additions & 1 deletion src/Cryptol/TypeCheck.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module Cryptol.TypeCheck
, InferInput(..)
, InferOutput(..)
, SolverConfig(..)
, defaultSolverConfig
, NameSeeds
, nameSeeds
, Error(..)
Expand Down Expand Up @@ -49,7 +50,7 @@ import Cryptol.TypeCheck.Monad
, io
)
import Cryptol.TypeCheck.Infer (inferModule, inferBinds, checkTopDecls)
import Cryptol.TypeCheck.InferTypes(VarType(..), SolverConfig(..))
import Cryptol.TypeCheck.InferTypes(VarType(..), SolverConfig(..), defaultSolverConfig)
import Cryptol.TypeCheck.Solve(proveModuleTopLevel)
import Cryptol.TypeCheck.CheckModuleInstance(checkModuleInstance)
-- import Cryptol.TypeCheck.Monad(withParamType,withParameterConstraints)
Expand Down
12 changes: 12 additions & 0 deletions src/Cryptol/TypeCheck/InferTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ data SolverConfig = SolverConfig
} deriving (Show, Generic, NFData)


-- | A default configuration for using Z3, where
-- the solver prelude is expected to be found
-- in the given search path.
defaultSolverConfig :: [FilePath] -> SolverConfig
defaultSolverConfig searchPath =
SolverConfig
{ solverPath = "z3"
, solverArgs = [ "-smt2", "-in" ]
, solverVerbose = 0
, solverPreludePath = searchPath
}

-- | The types of variables in the environment.
data VarType = ExtVar Schema
-- ^ Known type
Expand Down
1 change: 1 addition & 0 deletions src/Cryptol/TypeCheck/Solver/SMT.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ data Solver = Solver
-- ^ For debugging
}


-- | Start a fresh solver instance
startSolver :: SolverConfig -> IO Solver
startSolver SolverConfig { .. } =
Expand Down
1 change: 1 addition & 0 deletions src/Cryptol/Utils/Ident.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module Cryptol.Utils.Ident
, apPathRoot
, modPathCommon
, topModuleFor
, modPathSplit

, ModName
, modNameToText
Expand Down

0 comments on commit 51e5d91

Please sign in to comment.