claferIG 0.5.8 → 0.6.0
raw patch · 12 files changed
+101/−47 lines, 12 filesdep ~claferdep ~claferIGPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: clafer, claferIG
API changes (from Hackage documentation)
+ Language.Clafer.IG.Version: buildDate :: String
+ Language.Clafer.IG.Version: claferIGVersion :: String
- Language.Clafer.IG.Constraints: parseConstraints :: [ModelFile] -> IModule -> [(Span, IrTrace)] -> [Constraint]
+ Language.Clafer.IG.Constraints: parseConstraints :: [ModelFile] -> IModule -> Maybe IModule -> [(Span, IrTrace)] -> [Constraint]
Files
- CHANGES.md +10/−0
- LICENSE +1/−1
- README.md +5/−3
- claferIG.cabal +8/−7
- src/Language/Clafer/IG/AlloyIGInterface.hs +3/−7
- src/Language/Clafer/IG/ClaferIG.hs +8/−12
- src/Language/Clafer/IG/ClaferModel.hs +1/−1
- src/Language/Clafer/IG/CommandLine.hs +11/−10
- src/Language/Clafer/IG/Constraints.hs +6/−3
- src/Language/Clafer/IG/Process.hs +2/−2
- src/Language/Clafer/IG/Version.hs +45/−0
- stack.yaml +1/−1
CHANGES.md view
@@ -1,3 +1,13 @@+##### ClaferIG Version 0.6.0, Nov 29, 2026++Minor release with Clafer 0.6.0.++* `claferIG --version` and the help of the interactive mode print the build date, as clafer and chocosolver do: `ClaferIG v0.6.0.2026-11-29`. It is the day of the build, or of `SOURCE_DATE_EPOCH` when it is set (`Language.Clafer.IG.Version`). The unused generator `src/dateVer.hs` is removed.++* Unsat cores show the constraints of `initial` with their clafers, e.g., `initial xor on -->> off ... (tmp_TrafficLight1.cfr:4:9)`, and `c` marks their lines. They showed another expression of the model, e.g., `off (tmp_TrafficLight1.cfr:4:29)`, because their pids were empty; claferIG now also looks the pids up in the core that the Alloy model comes from. They are what clafersg shows for the same models.++* Builds with GHC 9.12.4 (Stackage nightly-2026-11-15) and still with GHC 9.6.7.+ ##### ClaferIG Version 0.5.8, Nov 15, 2026 Minor release with Clafer 0.5.8.
LICENSE view
@@ -1,5 +1,5 @@ Copyright 2012-2019 Generative Software Development Lab <http://gsd.uwaterloo.ca>-Copyright 2019-2023 Intelligent Systems Development Lab <https://uwaterloo.ca/wise-lab/>+Copyright 2019-2026 Waterloo Intelligent Systems Engineering Lab, University of Waterloo <https://uwaterloo.ca/wise-lab/> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in
README.md view
@@ -1,6 +1,6 @@ # Clafer Instance Generator -##### v0.5.8+##### v0.6.0 [Clafer](http://clafer.org) is a powerful (equivalent to first-order predicate logic) yet lightweight structural modeling language. Despite simplicity and conciseness of Clafer, writing correct models remains challenging due to hard-to-predict interactions among all constraints expressed in the model. @@ -129,7 +129,7 @@ (As printed by `claferIG --help`) ```-ClaferIG 0.5.8+ClaferIG v0.6.0.2026-11-29 claferig [OPTIONS] FILE @@ -336,7 +336,9 @@ In the interactive mode, the users can invoke the following commands by pressing a letter marked in the command name between '' or the whole command as marked by '': ```-ClaferIG v0.5.8+------------------------------+| ClaferIG v0.6.0.2026-11-29 |+------------------------------ You can invoke the following commands as indicated by single quotes: [tab] - print the available commands
claferIG.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.8 name: claferIG-Version: 0.5.8+Version: 0.6.0 Synopsis: claferIG is an interactive tool that generates instances of Clafer models. Description: Clafer is a powerful (equivalent to first-order predicate logic) yet lightweight structural modeling language. Despite simplicity and conciseness of Clafer, writing correct models remains challenging due to hard-to-predict interactions among all constraints expressed in the model. Clafer instance generator (ClaferIG) is an interactive tool that generates instances and counter examples of concrete clafers in a Clafer model. If the concrete clafers do not have contradicting constraints, the generator produces valid instance data. Otherwise, the generator produces an unsatisfiable core which included all contradicting constraints and generates a counter example by removing one constraint from the core. The generator can potentially produce many instances if the concrete clafers are not fully specialized. The generator produces different instances on-demand. With these capabilities, the instance generator can be used for debugging models: checking the consistency of the model and detecting under- and overconstraining of the model. The instance generator can also be used programmatically via API (the command line and interactive session interfaces only use the API). Homepage: http://clafer.org@@ -40,8 +40,8 @@ Main-is: Main.hs Build-depends: filepath >= 1.3.0.2 , cmdargs >= 0.10.12- , clafer == 0.5.8- , claferIG == 0.5.8+ , clafer == 0.6.0+ , claferIG == 0.6.0 other-modules: Paths_claferIG autogen-modules: Paths_claferIG Hs-Source-Dirs: src-cmd@@ -58,7 +58,7 @@ , exceptions >= 0.10 , aeson >= 1.1.2.0 , string-conversions >= 0.3.0.3- , clafer == 0.5.8+ , clafer == 0.6.0 if os(windows) build-depends: HaXml == 1.24@@ -78,6 +78,7 @@ , Language.Clafer.IG.Solution , Language.Clafer.IG.SolutionView , Language.Clafer.IG.Sugarer+ , Language.Clafer.IG.Version other-modules: Paths_claferIG autogen-modules: Paths_claferIG Test-Suite test-suite@@ -89,7 +90,7 @@ , tasty >= 0.10.1.2 , tasty-hunit >= 0.9.2 , tasty-th >= 0.1.3- , claferIG == 0.5.8+ , claferIG == 0.6.0 other-modules: Paths_claferIG autogen-modules: Paths_claferIG ghc-options: -Wall -fno-warn-orphans@@ -109,7 +110,7 @@ , tasty >= 0.10.1.2 , tasty-hunit >= 0.9.2 , tasty-th >= 0.1.3- , clafer == 0.5.8- , claferIG == 0.5.8+ , clafer == 0.6.0+ , claferIG == 0.6.0 -- the tests run in parallel, on 8 cores: with GHC 9.12 and 16 or more, the parallel GC hangs ghc-options: -Wall -fno-warn-orphans -threaded -rtsopts "-with-rtsopts=-N8"
src/Language/Clafer/IG/AlloyIGInterface.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE GeneralizedNewtypeDeriving, StandaloneDeriving #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-} {- Copyright (C) 2012-2017 Jimmy Liang <http://gsd.uwaterloo.ca>@@ -162,9 +162,7 @@ mapM_ resetScope sigs where resetScope Sig{s_name = name, s_startingScope = startingScope} =- case startingScope of- Just scope -> sendSetScopeCommand name scope >> return ()- Nothing -> sendSetScopeCommand name 1 >> return ()+ void $ sendSetScopeCommand name $ fromMaybe 1 startingScope -- | Get the next solution from alloyIG@@ -194,9 +192,7 @@ getScope sig = do rscopes <- fetches scopes- case Map.lookup sig rscopes of- Just scope -> return scope- Nothing -> getGlobalScope+ maybe getGlobalScope return $ Map.lookup sig rscopes getScopes :: MonadIO m => AlloyIGT m [(String, Integer)]
src/Language/Clafer/IG/ClaferIG.hs view
@@ -103,13 +103,9 @@ import qualified Data.Set as Set import Data.Maybe import Data.Data-import Paths_claferIG (version)-import Data.Version (showVersion)+import Language.Clafer.IG.Version (claferIGVersion) import Prelude -claferIGVersion :: String-claferIGVersion = "ClaferIG " ++ showVersion Paths_claferIG.version- data IGArgs = IGArgs { all :: Maybe Integer, maxInstances :: Maybe Integer,@@ -134,7 +130,7 @@ skip_resolver_comp :: Bool, scope_strategy_comp :: ScopeStrategy -} deriving (Show, Data, Typeable)+} deriving (Show, Data) newtype ClaferIGT m a = ClaferIGT (StateT ClaferIGEnv (AlloyIGT m) a) deriving (Applicative, Functor, Monad, MonadIO, MonadThrow, MonadCatch, MonadMask)@@ -229,14 +225,14 @@ -- the integer range of the options (--maxint, --minint) raises the bitwidth bitwidth' = maximum $ bitwidth igArgs : map requiredBitwidth (catMaybes [maxint claferArgs', (\n -> -n - 1) <$> minint claferArgs']) - (claferEnv', alloyModel, mapping, sMap, dynamic) <- ExceptT $ return $ mapLeft (inFiles modelFiles') $ callClaferTranslator claferArgs' claferModel+ (claferEnv', alloyModel, mapping, sMap, dynamic, core) <- ExceptT $ return $ mapLeft (inFiles modelFiles') $ callClaferTranslator claferArgs' claferModel let (ir0, genv', _) = fromJust $ cIr claferEnv' -- the clafers by their Alloy names, as in the Alloy model names = alloyNames ir0 ir = toAlloyNames names ir0- let constraints = parseConstraints modelFiles' ir mapping+ let constraints = parseConstraints modelFiles' ir core mapping lift $ AlloyIG.sendLoadCommand alloyModel lift $ AlloyIG.sendSetBitwidthCommand bitwidth'@@ -252,7 +248,7 @@ editMap :: Map.Map Span [Ir] -> Map.Map Integer String -- Map Line Number to Clafer Name editMap = fromList . removeConstraints . Data.List.foldr (\(num, ir) acc -> case getIClafer ir of- Just (IClafer _ _ _ _ uid' _ _ _ _ _ _) -> (num, uid') : acc+ Just IClafer{_uid = uid'} -> (num, uid') : acc _ -> acc) [] . (Data.List.foldr (\((Span (Pos l1 _) (Pos l2 _)), irs) acc -> (zip [l1..l2] (replicate (fromIntegral $ l2 - l1 + 1) irs)) ++ acc) []) . toList getIClafer :: [Ir] -> Maybe IClafer getIClafer [] = Nothing@@ -276,7 +272,7 @@ throwErr (ClaferErr reason' :: ClaferSErr) -- a dynamic model compiles to a temporal Alloy model (tmp.als) (Just alloyResult) ->- return (claferEnv alloyResult, outputCode alloyResult, mappingToAlloy alloyResult, stringMap alloyResult, extension alloyResult == "tmp.als")+ return (claferEnv alloyResult, outputCode alloyResult, mappingToAlloy alloyResult, stringMap alloyResult, extension alloyResult == "tmp.als", alloyModule alloyResult) mapLeft f (Left l) = Left $ f l mapLeft _ (Right r) = Right r -- the options given to claferIG take precedence over the files' options@@ -532,10 +528,10 @@ in Data.List.filter (removeAbsZero absIDs ) $ map (\c -> find ((== c) . range) constraints') core where removeAbsZero :: Seq.Seq String -> Maybe Constraint -> Bool- removeAbsZero absIDs (Just (UpperCardinalityConstraint _ (ClaferInfo uID (Cardinality 0 (Just 0))))) = ((Seq.elemIndexL uID absIDs)==Nothing)+ removeAbsZero absIDs (Just (UpperCardinalityConstraint _ (ClaferInfo uID (Cardinality 0 (Just 0))))) = isNothing (Seq.elemIndexL uID absIDs) removeAbsZero _ _ = True getId :: Ir -> Seq.Seq String- getId (IRClafer (IClafer _ IClaferModifiers{_abstract=True} _ uID _ _ _ _ _ _ _)) = Seq.singleton uID+ getId (IRClafer IClafer{_modifiers = IClaferModifiers{_abstract=True}, _ident = uID}) = Seq.singleton uID getId _ = mempty getIMod :: (IModule, GEnv, Bool) -> IModule
src/Language/Clafer/IG/ClaferModel.hs view
@@ -127,7 +127,7 @@ buildFields fields where asNodes :: Sig -> [Node]- asNodes Sig{s_id = id, s_atoms = atoms} = map (flip ClaferNode id) $ map (labelAsId . a_label) atoms+ asNodes Sig{s_id = id, s_atoms = atoms} = map (flip ClaferNode id . labelAsId . a_label) atoms rootNodes :: [(Id, Node)] rootNodes = [(n_id rootNode, rootNode) | rootNode <- concatMap asNodes sigs]
src/Language/Clafer/IG/CommandLine.hs view
@@ -177,10 +177,11 @@ loop Help context = do+ let rule = replicate (length claferIGVersion + 4) '-' outputStrLn (- "------------------\n" +++ rule ++ "\n" ++ "| " ++ claferIGVersion ++ " |\n" ++- "------------------\n\n" +++ rule ++ "\n\n" ++ "You can invoke the following commands as indicated by single quotes:\n" ++ "[tab] - print the available commands\n" ++ " - auto-complete command name, a clafer name, or clafer instance name in a given context\n" ++@@ -728,13 +729,13 @@ autoCompleteDetect :: E.ParseError -> AutoComplete autoCompleteDetect error' -- An unexpected message means that parsing failed before eof- | any (not . null) unexpectedMessages = No_Auto- | any (== "command") expectedMessages = Auto_Command- | any (== "clafer") expectedMessages = Auto_Clafer- | any (== "claferInstance") expectedMessages = Auto_ClaferInstance- | any (== "Unsat core minimization level") expectedMessages = Auto_UnsatCoreMinimization- | any (== "digit") expectedMessages = Auto_Digit- | any (== "space") expectedMessages = Auto_Space+ | not (Prelude.all null unexpectedMessages) = No_Auto+ | "command" `elem` expectedMessages = Auto_Command+ | "clafer" `elem` expectedMessages = Auto_Clafer+ | "claferInstance" `elem` expectedMessages = Auto_ClaferInstance+ | "Unsat core minimization level" `elem` expectedMessages = Auto_UnsatCoreMinimization+ | "digit" `elem` expectedMessages = Auto_Digit+ | "space" `elem` expectedMessages = Auto_Space | otherwise = No_Auto where messages = errorMessages error'@@ -772,7 +773,7 @@ removeCommentsAndUnify (c:model) = c : removeCommentsAndUnify model isEmptyLine :: String -> Bool-isEmptyLine l = filter (`notElem` [' ', '\n', '\t', '\r']) l == []+isEmptyLine = Prelude.all (`elem` [' ', '\n', '\t', '\r']) numberOfDigits :: Int -> Int numberOfDigits x = length $ show x
src/Language/Clafer/IG/Constraints.hs view
@@ -95,12 +95,15 @@ cs -> minimumBy (comparing $ to . range) cs -parseConstraints :: [ModelFile] -> IModule -> [(Span, IrTrace)] -> [Constraint]-parseConstraints modelFiles imodule mapping =+-- | The constraints of the Alloy code by their regions, from the rich IR, or else from the core that+-- the code was generated from, e.g., the constraints of the modifiers @initial@ and @final@.+parseConstraints :: [ModelFile] -> IModule -> Maybe IModule -> [(Span, IrTrace)] -> [Constraint]+parseConstraints modelFiles imodule core mapping = mapMaybe (uncurry convert) mapping where clafers = _mDecls imodule >>= subclafers- pexps = (mapMaybe constraint $ _mDecls imodule ++ concatMap _elements clafers) >>= subexpressions+ pexps = expressions imodule ++ maybe [] expressions core+ expressions m = (mapMaybe constraint $ _mDecls m ++ concatMap _elements (_mDecls m >>= subclafers)) >>= subexpressions convert s IrPExp{pUid} = Just $ UserConstraint s $ constraintInfoOf modelFiles $ findPExp pUid convert s LowerCard{pUid, isGroup = False} =
src/Language/Clafer/IG/Process.hs view
@@ -67,7 +67,7 @@ getMessage proce = liftIO $ do len <- read `liftM` hGetLine (stdOut proce)- mapM hGetChar $ replicate len (stdOut proce)+ replicateM len $ hGetChar (stdOut proce) readMessage :: (Read r, MonadIO m) => Process -> m r readMessage proce = read `liftM` getMessage proce@@ -76,7 +76,7 @@ putMessage :: MonadIO m => Process -> String -> m () putMessage proce message = liftIO $ do- hPutStrLn (stdIn proce) (show $ length message)+ hPrint (stdIn proce) (length message) hPutStr (stdIn proce) message hFlush (stdIn proce)
+ src/Language/Clafer/IG/Version.hs view
@@ -0,0 +1,45 @@+{-# LANGUAGE TemplateHaskell #-}+{-# OPTIONS_GHC -fforce-recomp #-}+{-+ Copyright (C) 2026 Michal Antkiewicz <http://gsd.uwaterloo.ca>++ Permission is hereby granted, free of charge, to any person obtaining a copy of+ this software and associated documentation files (the "Software"), to deal in+ the Software without restriction, including without limitation the rights to+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies+ of the Software, and to permit persons to whom the Software is furnished to do+ so, subject to the following conditions:++ The above copyright notice and this permission notice shall be included in all+ copies or substantial portions of the Software.++ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+ SOFTWARE.+-}+-- | The version of claferIG with its build date, as @claferIG --version@ prints it:+-- @ClaferIG v0.6.0.2026-11-29@, the format of @clafer --version@ and @chocosolver --version@.+--+-- The build date is the day this module was compiled, or the day of @SOURCE_DATE_EPOCH@+-- ("Language.Clafer.BuildDate"). It is compiled in every build (@-fforce-recomp@), so the date+-- is never one of an earlier build; the other modules see no change, since 'buildDate' is not+-- inlined, and are only linked again.+module Language.Clafer.IG.Version (buildDate, claferIGVersion) where++import Data.Version (showVersion)++import Language.Clafer.BuildDate (buildDateQ)+import qualified Paths_claferIG++-- | The day claferIG was built, @YYYY-MM-DD@.+buildDate :: String+buildDate = $(buildDateQ)+{-# NOINLINE buildDate #-}++-- | @ClaferIG v0.6.0.2026-11-29@: the version and the build date.+claferIGVersion :: String+claferIGVersion = "ClaferIG v" ++ showVersion Paths_claferIG.version ++ "." ++ buildDate
stack.yaml view
@@ -1,5 +1,5 @@ # for GHC-9.12.4-resolver: nightly-2026-11-11+resolver: nightly-2026-11-15 flags: # The test suites that need the models in the repositories (and Alloy for claferIG).