call-alloy 0.3.0.1 → 0.3.0.2
raw patch · 4 files changed
+31/−58 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +4/−0
- README.md +1/−1
- call-alloy.cabal +1/−1
- src/Language/Alloy/Internal/Call.hs +25/−56
ChangeLog.md view
@@ -4,6 +4,10 @@ ## Released changes +### 0.3.0.2++- fix runtime error on PARTIAL_INSTANCE+ ### 0.3.0.1 - support "State0" line in retrieved instances (introduced by Alloy 6)
README.md view
@@ -1,4 +1,4 @@-# `call-alloy` [](https://travis-ci.org/marcellussiegburg/call-alloy)+# `call-alloy` [](https://github.com/marcellussiegburg/call-alloy/actions?query=workflow%3A%22Haskell+CI%22+branch%3Amaster) This is a simple library to call [Alloy](http://alloytools.org) given a specification. This package includes a simple Java Library to make an API call to the Alloy Library.
call-alloy.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: call-alloy-version: 0.3.0.1+version: 0.3.0.2 synopsis: A simple library to call Alloy given a specification description: Please see the README on GitHub at <https://github.com/marcellussiegburg/call-alloy#readme> category: Language
src/Language/Alloy/Internal/Call.hs view
@@ -17,8 +17,12 @@ getRawInstancesWith, ) where -import qualified Data.ByteString as BS- (hGetLine, intercalate, isSuffixOf, stripPrefix, writeFile)+import qualified Data.ByteString as BS (+ hGetLine,+ intercalate,+ stripPrefix,+ writeFile,+ ) import qualified Data.ByteString.Char8 as BS (unlines) import Control.Concurrent (@@ -154,15 +158,14 @@ out <- getOutput pout err <- getOutput perr printContentOnError ph- let err' = removeInfoPrefix err+ let err' = removeInfoLines err unless (null err') $ fail $ unpack $ BS.unlines err'- let instas = fmap (BS.intercalate "\n") $ drop 1 $ splitOn [begin] out- return $ filterLast (not . (partialInstance `BS.isSuffixOf`)) instas+ return $ fmap (BS.intercalate "\n")+ $ filterLast ((/= partialInstance) . last)+ $ drop 1 $ splitOn [begin] out where begin :: ByteString begin = "---INSTANCE---"- partialInstance :: ByteString- partialInstance = "---PARTIAL_INSTANCE---" filterLast _ [] = [] filterLast p x@[_] = filter p x filterLast p (x:xs) = x:filterLast p xs@@ -186,6 +189,9 @@ killThread pid return output +partialInstance :: ByteString+partialInstance = "---PARTIAL_INSTANCE---"+ {-| Removes lines such as @@ -197,13 +203,21 @@ [main] INFO kodkod.engine.config.Reporter - generating lex-leader symmetry breaking predicate ... @ +and++@+PARTIAL_INSTANCE+@+ which seem to be appearing since Alloy-6.0.0 -}-removeInfoPrefix :: [ByteString] -> [ByteString]-removeInfoPrefix (x:xs)+removeInfoLines :: [ByteString] -> [ByteString]+removeInfoLines (x:xs) | Just _ <- BS.stripPrefix "[main] INFO" x- = removeInfoPrefix xs-removeInfoPrefix xs = xs+ = removeInfoLines xs+ | x == partialInstance+ = removeInfoLines xs+removeInfoLines xs = xs {-| Start a new process that aborts execution by closing all handles and@@ -236,51 +250,6 @@ getClassPath = do mclassPath' <- readIORef mclassPath maybe readClassPath return mclassPath'--{--{--data CallAlloyConfig = Config {- alloyJarFile :: FilePath,- alloyClassFile :: FilePath,- keepFiles :: Bool- }--}--jarFileEnv :: String-jarFileEnv = "ALLOY_JAR_FILE"--callAlloyEnv :: String-callAlloyEnv = "CALL_ALLOY_CLASS_FILE"--keepFilesEnv :: String-keepFilesEnv = "KEEP_ALLOY_FILES"--{-|-Lookup environment variables which are to prefer if present.--}-getEnvironmentInformation :: IO CallAlloyConfig-getEnvironmentInformation = do- alloy <- lookupEnv jarFileEnv- callAlloy <- lookupEnv callAlloyEnv- keep <- lookupEnv keepFilesEnv- let mconfig = Config <$> alloy <*> callAlloy <*> pure (isJust keep)- case mconfig of- Nothing -> do- dataDir <- getXdgDirectory XdgData $ appName </> "dataDir"- Just c -> return c--}-{--getVersionFile :: IO FilePath-getVersionFile = do- configDir <- getXdgDirectory XdgConfig appName- let versionFile = configDir </> "version"- exists <- doesFileExist versionFile- if exists- then do- version <- read <$> readFile versionFile- unless (version == versionHash) $ createVersionFile configDir versionFile- else createVersionFile configDir versionFile--} fallbackToTempDir :: IO FilePath -> IO FilePath fallbackToTempDir m = catch m $ \e ->