Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose modPathSplit and defaultSolverConfig for downstream use #1165

Merged
merged 1 commit into from
Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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