diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index a52a680..5bd09bf 100644 --- a/.github/workflows/haskell-ci.yml +++ b/.github/workflows/haskell-ci.yml @@ -28,6 +28,11 @@ jobs: strategy: matrix: include: + - compiler: ghc-9.10.1 + compilerKind: ghc + compilerVersion: 9.10.1 + setup-method: ghcup + allow-failure: false - compiler: ghc-9.8.2 compilerKind: ghc compilerVersion: 9.8.2 diff --git a/CHANGELOG.md b/CHANGELOG.md index a2fbef0..78f9ac7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [PVP versioning](https://pvp.haskell.org/). +## v2.8.1 _(2024-11-29)_ + +### Added +- Added instances `Semigroup`, `Monoid` and `Contravariant` for `Debugger` + ## v2.8.0 _(2024-11-28)_ ### Changed diff --git a/hasmtlib.cabal b/hasmtlib.cabal index fed6fd9..1e8cca7 100644 --- a/hasmtlib.cabal +++ b/hasmtlib.cabal @@ -1,7 +1,7 @@ cabal-version: 3.0 name: hasmtlib -version: 2.8.0 +version: 2.8.1 synopsis: A monad for interfacing with external SMT solvers description: Hasmtlib is a library for generating SMTLib2-problems using a monad. It takes care of encoding your problem, marshaling the data to an external solver and parsing and interpreting the result into Haskell types. @@ -21,6 +21,7 @@ extra-doc-files: CHANGELOG.md tested-with: GHC == 9.4.8 , GHC == 9.6.4 , GHC == 9.8.2 + , GHC == 9.10.1 library hs-source-dirs: src @@ -60,8 +61,8 @@ library build-depends: array >= 0.5 && < 1 , attoparsec >= 0.14.4 && < 1 , base >= 4.17.2 && < 5 - , lifted-base >= 0.2 && < 0.5 - , monad-control >= 1.0 && < 1.2 + , lifted-base >= 0.2 && < 0.5 + , monad-control >= 1.0 && < 1.2 , bytestring >= 0.11.5 && < 1 , containers >= 0.6.7 && < 1 , unordered-containers >= 0.2.20 && < 0.3 diff --git a/src/Language/Hasmtlib/Type/Debugger.hs b/src/Language/Hasmtlib/Type/Debugger.hs index 20fc32c..ff5976d 100644 --- a/src/Language/Hasmtlib/Type/Debugger.hs +++ b/src/Language/Hasmtlib/Type/Debugger.hs @@ -19,7 +19,6 @@ module Language.Hasmtlib.Type.Debugger , assertionish , incrementalStackish, getValueish , responseish - ) where @@ -34,6 +33,7 @@ import Data.ByteString.Lazy.UTF8 (toString) import Data.ByteString.Builder import qualified Data.ByteString.Lazy.Char8 as ByteString.Char8 import Data.Default +import Data.Functor.Contravariant import Control.Lens hiding (op) -- | A type holding actions for debugging states holding SMT-Problems. @@ -58,6 +58,33 @@ data Debugger s = Debugger instance Default (Debugger s) where def = verbosely +-- | Concats actions +instance Semigroup (Debugger s) where + x <> y = Debugger + (\input -> debugState x input >> debugState y input) + (\input -> debugOption x input >> debugOption y input) + (\input -> debugLogic x input >> debugLogic y input) + (\input -> debugVar x input >> debugVar y input) + (\input -> debugAssert x input >> debugAssert y input) + (\input -> debugPop x input >> debugPop y input) + (\input -> debugCheckSat x input >> debugCheckSat y input) + (\input -> debugGetModel x input >> debugGetModel y input) + (\input -> debugGetValue x input >> debugGetValue y input) + (\input -> debugMinimize x input >> debugMinimize y input) + (\input -> debugMaximize x input >> debugMaximize y input) + (\input -> debugMaximize x input >> debugMaximize y input) + (\input -> debugAssertSoft x input >> debugAssertSoft y input) + (\input -> debugResultResponse x input >> debugResultResponse y input) + (\input -> debugModelResponse x input >> debugModelResponse y input) + +instance Monoid (Debugger s) where + mempty = silently + +instance Contravariant Debugger where + contramap f' debugger = debugger { debugState = f . f' } + where + f = debugState debugger + printer :: Builder -> IO () printer = ByteString.Char8.putStrLn . toLazyByteString