Skip to content

Commit

Permalink
fixup errors
Browse files Browse the repository at this point in the history
  • Loading branch information
glguy committed Dec 18, 2024
1 parent 13ff72a commit 67a4d29
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Cryptol/Project/Cache.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ data FullFingerprint = FullFingerprint
-- XXX: This should probably be a parameter
metaDir, loadCachePath :: FilePath
metaDir = ".cryproject"
loadCachePath = metaDir FP.</> "loadcache"
loadCachePath = metaDir FP.</> "loadcache.toml"

emptyLoadCache :: LoadCache
emptyLoadCache = LoadCache { cacheModules = mempty }
Expand Down
7 changes: 1 addition & 6 deletions src/Cryptol/Project/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ data ConfigLoadErrorInfo
instance PP ConfigLoadError where
ppPrec _ (ConfigLoadError path info) =
case info of
ConfigParseError errs -> text $ unlines errs
{-
show topMsg ++ prettyPosWithSource pos file "\nParse error:" ++ err
-}
ConfigParseError errs -> text (unlines errs)
SetRootFailed ioe ->
hang topMsg
4 (hang "Failed to set project root:"
Expand All @@ -63,5 +60,3 @@ loadConfig path =
tryIOError
do setCurrentDirectory (takeDirectory filePath FP.</> root config)
pure config


17 changes: 7 additions & 10 deletions src/Cryptol/REPL/Command.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,7 @@ getPrimMap = liftModuleCmd M.getPrimMap
liftModuleCmd :: M.ModuleCmd a -> REPL a
liftModuleCmd cmd = moduleCmdResult =<< io . cmd =<< getModuleInput

-- TODO: add filter for my exhaustie prop guards warning here
-- TODO: add filter for my exhaustive prop guards warning here

printModuleWarnings :: [M.ModuleWarning] -> REPL ()
printModuleWarnings ws0 = do
Expand Down Expand Up @@ -2259,17 +2259,17 @@ loadProjectREPL cfg =
M.InFile path ->
case v of
Proj.Invalid e ->
do rPutStrLn ("Failed to process module: " ++ path ++ ":\n" ++ ppInvalidStatus e)
do rPrint ("Failed to process module: " <> text path <> ":" $$ ppInvalidStatus e)
pure (fpAcc, False) -- report failure
Proj.Scanned Proj.Unchanged _ ((m,_):_) ->
do let name = P.thing (P.mName m)
rPutStrLn ("Skipping unmodified module: " ++ show (pp name))
rPrint ("Skipping unmodified module: " <> pp name)
let prevResult = join (Map.lookup (Proj.CacheInFile path) docstringResults)
let fpAcc' = Map.adjust (\e -> e{ Proj.cacheDocstringResult = prevResult }) (Proj.CacheInFile path) fpAcc
pure (fpAcc', success) -- preserve success
Proj.Scanned Proj.Changed _ ((m,_):_) ->
do let name = P.thing (P.mName m)
rPutStrLn ("Checking docstrings on changed module: " ++ show (pp name))
rPrint ("Checking docstrings on changed module: " <> pp name)
checkRes <- checkModName name
let fpAcc' = Map.adjust (\fp -> fp { Proj.cacheDocstringResult = Just (crSuccess checkRes) }) (Proj.CacheInFile path) fpAcc
pure (fpAcc', success && crSuccess checkRes)
Expand All @@ -2291,10 +2291,7 @@ loadProjectREPL cfg =
io (Proj.saveLoadCache (Proj.LoadCache cache))
pure emptyCommandResult { crSuccess = success }

ppInvalidStatus :: Proj.InvalidStatus -> String
ppInvalidStatus :: Proj.InvalidStatus -> Doc
ppInvalidStatus = \case
Proj.InvalidModule modErr -> indentStr (show (pp modErr))
Proj.InvalidDep d _ -> indentStr ("Error in dependency: " ++ show (pp d))

indentStr :: String -> String
indentStr = unlines . map (" "++) . lines
Proj.InvalidModule modErr -> pp modErr
Proj.InvalidDep d _ -> "Error in dependency: " <> pp d

0 comments on commit 67a4d29

Please sign in to comment.