packages feed

simple-smt 0.5.5 → 0.6.0

raw patch · 3 files changed

+47/−12 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ SimpleSMT: logIndented :: Logger -> IO a -> IO a
+ SimpleSMT: logLevel :: Logger -> IO Int
+ SimpleSMT: logMessageAt :: Logger -> Int -> String -> IO ()
+ SimpleSMT: logSetLevel :: Logger -> Int -> IO ()
+ SimpleSMT: withLogLevel :: Logger -> Int -> IO a -> IO a
- SimpleSMT: Logger :: (String -> IO ()) -> IO () -> IO () -> Logger
+ SimpleSMT: Logger :: (String -> IO ()) -> IO Int -> (Int -> IO ()) -> IO () -> IO () -> Logger
- SimpleSMT: newLogger :: IO Logger
+ SimpleSMT: newLogger :: Int -> IO Logger

Files

CHANGES view
@@ -1,3 +1,5 @@+0.6.0: Allow finer-grained logging+0.5.5: Add support for unsupported results 0.5.3: Add 'zeroExtend' and 'signExtend' 0.5.2: Fix right shift 0.5.1:  Add 'define' commands
SimpleSMT.hs view
@@ -20,6 +20,9 @@     -- ** Logging and Debugging   , Logger(..)   , newLogger+  , withLogLevel+  , logMessageAt+  , logIndented      -- * Common SmtLib-2 Commands   , setLogic, setLogicMaybe@@ -120,13 +123,14 @@ import Data.Char(isSpace) import Data.List(unfoldr) import Data.Bits(testBit)-import Data.IORef(newIORef, atomicModifyIORef, modifyIORef', readIORef)+import Data.IORef(newIORef, atomicModifyIORef, modifyIORef', readIORef,+                  writeIORef) import System.Process(runInteractiveProcess, waitForProcess) import System.IO (hFlush, hGetLine, hGetContents, hPutStrLn, stdout) import System.Exit(ExitCode) import qualified Control.Exception as X import Control.Concurrent(forkIO)-import Control.Monad(forever)+import Control.Monad(forever,when) import Text.Read(readMaybe) import Data.Ratio((%), numerator, denominator) import Numeric(showHex, readHex)@@ -740,6 +744,10 @@   { logMessage :: String -> IO ()     -- ^ Log a message. +  , logLevel   :: IO Int++  , logSetLevel:: Int -> IO ()+   , logTab     :: IO ()     -- ^ Increase indentation. @@ -747,16 +755,41 @@     -- ^ Decrease indentation.   } --- | A simple stdout logger.-newLogger :: IO Logger-newLogger =+-- | Run an IO action with the logger set to a specific level, restoring it when+-- done.+withLogLevel :: Logger -> Int -> IO a -> IO a+withLogLevel Logger { .. } l m =+  do l0 <- logLevel+     X.bracket_ (logSetLevel l) (logSetLevel l0) m++logIndented :: Logger -> IO a -> IO a+logIndented Logger { .. } = X.bracket_ logTab logUntab++-- | Log a message at a specific log level.+logMessageAt :: Logger -> Int -> String -> IO ()+logMessageAt logger l msg = withLogLevel logger l (logMessage logger msg)++-- | A simple stdout logger.  Shows only messages logged at a level that is+-- greater than or equal to the passed level.+newLogger :: Int -> IO Logger+newLogger l =   do tab <- newIORef 0-     let logMessage x = do let ls = lines x-                           t <- readIORef tab-                           putStr $ unlines [ replicate t ' ' ++ l | l <- ls ]-                           hFlush stdout-         logTab   = modifyIORef' tab (+ 2)-         logUntab = modifyIORef' tab (subtract 2)+     lev <- newIORef 0+     let logLevel    = readIORef lev+         logSetLevel = writeIORef lev++         shouldLog m =+           do cl <- logLevel+              when (cl >= l) m++         logMessage x = shouldLog $+           do let ls = lines x+              t <- readIORef tab+              putStr $ unlines [ replicate t ' ' ++ l | l <- ls ]+              hFlush stdout++         logTab   = shouldLog (modifyIORef' tab (+ 2))+         logUntab = shouldLog (modifyIORef' tab (subtract 2))      return Logger { .. }  
simple-smt.cabal view
@@ -1,5 +1,5 @@ name:                simple-smt-version:             0.5.5+version:             0.6.0 synopsis:            A simple way to interact with an SMT solver process. description:         A simple way to interact with an SMT solver process. license:             BSD3