aboutsummaryrefslogtreecommitdiffstats
path: root/src/VeriFuzz/Sim/Internal.hs
diff options
context:
space:
mode:
authorYann Herklotz <git@ymhg.org>2019-05-13 16:32:41 +0100
committerYann Herklotz <git@ymhg.org>2019-05-13 16:32:41 +0100
commit98c6701f48d3e06eb0f2fcd590d0330aec8b5a9b (patch)
tree0f7d04a48fd28b9b14da74686b3fac27515362a4 /src/VeriFuzz/Sim/Internal.hs
parent2fa0419fcd066137e0fc2fdc6c8f4128a4a1e663 (diff)
downloadverismith-98c6701f48d3e06eb0f2fcd590d0330aec8b5a9b.tar.gz
verismith-98c6701f48d3e06eb0f2fcd590d0330aec8b5a9b.zip
Add ResultT to Sh conversion
Diffstat (limited to 'src/VeriFuzz/Sim/Internal.hs')
-rw-r--r--src/VeriFuzz/Sim/Internal.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/VeriFuzz/Sim/Internal.hs b/src/VeriFuzz/Sim/Internal.hs
index a11fbd3..091520c 100644
--- a/src/VeriFuzz/Sim/Internal.hs
+++ b/src/VeriFuzz/Sim/Internal.hs
@@ -14,6 +14,7 @@ Class of the simulator and the synthesize tool.
module VeriFuzz.Sim.Internal
( ResultSh
+ , resultSh
, Tool(..)
, Simulator(..)
, Synthesiser(..)
@@ -39,6 +40,7 @@ where
import Control.Lens
import Control.Monad (forM, void)
+import Control.Monad.Catch (throwM)
import Data.Bits (shiftL)
import Data.ByteString (ByteString)
import qualified Data.ByteString as B
@@ -51,6 +53,7 @@ import Prelude hiding (FilePath)
import Shelly
import Shelly.Lifted (MonadSh, liftSh)
import System.FilePath.Posix (takeBaseName)
+import VeriFuzz.Internal
import VeriFuzz.Result
import VeriFuzz.Verilog.AST
@@ -95,6 +98,13 @@ class Tool a => Synthesiser a where
-- with also has those instances.
type ResultSh = ResultT Failed Sh
+resultSh :: ResultSh a -> Sh a
+resultSh s = do
+ result <- runResultT s
+ case result of
+ Fail e -> throwM . RunFailed "" [] 1 $ showT e
+ Pass s' -> return s'
+
checkPresent :: FilePath -> Text -> Sh (Maybe Text)
checkPresent fp t = do
errExit False $ run_ "grep" [t, toTextIgnore fp]