Skip to content

Commit

Permalink
debugger: added instances Semigroup, Monoid, Contravariant
Browse files Browse the repository at this point in the history
  • Loading branch information
bruderj15 committed Nov 29, 2024
1 parent f0f5551 commit 9c8c3a3
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/Language/Hasmtlib/Type/Debugger.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ module Language.Hasmtlib.Type.Debugger
, assertionish
, incrementalStackish, getValueish
, responseish

)
where

Expand All @@ -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.
Expand All @@ -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

Expand Down

0 comments on commit 9c8c3a3

Please sign in to comment.