Skip to content

Commit

Permalink
Merge pull request #40 from tweag/qa/hlint
Browse files Browse the repository at this point in the history
apply hlint suggestions
  • Loading branch information
qaristote authored Jan 10, 2023
2 parents e3d0083 + de246d3 commit 5179a35
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
5 changes: 2 additions & 3 deletions smtlib-backends-process/src/SMTLIB/Backends/Process.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{-# LANGUAGE DisambiguateRecordFields #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ViewPatterns #-}

-- | A module providing a backend that launches solvers as external processes.
Expand Down Expand Up @@ -105,7 +104,7 @@ new config = do
IO.hClose h `X.catch` \ex ->
reportError' $ BS.pack $ show (ex :: X.IOException)
)
reportError' = (reportError config) . LBS.fromStrict
reportError' = reportError config . LBS.fromStrict

-- | Wait for the process to exit and cleanup its resources.
wait :: Handle -> IO ExitCode
Expand Down
4 changes: 2 additions & 2 deletions smtlib-backends-z3/src/SMTLIB/Backends/Z3.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ C.context
)
C.include "z3.h"

data Config = Config
newtype Config = Config
{ -- | A list of options to set during the solver's initialization.
-- Each pair is of the form @(paramId, paramValue)@, e.g.
-- @(":produce-models", "true")@.
Expand All @@ -61,7 +61,7 @@ data Config = Config
instance Default Config where
def = Config []

data Handle = Handle
newtype Handle = Handle
{ -- | A black-box representing the internal state of the solver.
context :: ForeignPtr Z3Context
}
Expand Down
3 changes: 2 additions & 1 deletion smtlib-backends-z3/tests/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import Test.Tasty.HUnit
main :: IO ()
main = do
defaultMain $
testGroup "Tests" $
testGroup
"Tests"
[ testBackend "Basic examples" validSources z3,
testGroup "API usage examples" examples,
testBackend "Error handling" failingSources z3
Expand Down
8 changes: 4 additions & 4 deletions src/SMTLIB/Backends.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections #-}

module SMTLIB.Backends
( Backend (..),
Expand All @@ -19,7 +20,7 @@ import Prelude hiding (log)

-- | The type of solver backends. SMTLib2 commands are sent to a backend which
-- processes them and outputs the solver's response.
data Backend = Backend
newtype Backend = Backend
{ -- | Send a command to the backend.
send :: Builder -> IO LBS.ByteString
}
Expand All @@ -39,8 +40,7 @@ putQueue q cmd = atomicModifyIORef q $ \cmds ->
-- | Empty the queue of commands to evaluate and return its content as a bytestring
-- builder.
flushQueue :: Queue -> IO Builder
flushQueue q = atomicModifyIORef q $ \cmds ->
(mempty, cmds)
flushQueue q = atomicModifyIORef q (mempty,)

-- | A solver is essentially a wrapper around a solver backend. It also comes with
-- a function for logging the solver's activity, and an optional queue of commands
Expand Down Expand Up @@ -107,7 +107,7 @@ command :: Solver -> Builder -> IO LBS.ByteString
command solver cmd = do
send (backend solver)
=<< case queue solver of
Nothing -> return $ cmd
Nothing -> return cmd
Just q -> (<> cmd) <$> flushQueue q

-- | A command with no interesting result.
Expand Down

0 comments on commit 5179a35

Please sign in to comment.