diff options
author | Yann Herklotz <git@yannherklotz.com> | 2019-12-26 01:34:52 +0100 |
---|---|---|
committer | Yann Herklotz <git@yannherklotz.com> | 2019-12-26 01:34:52 +0100 |
commit | ff5065834a9dc8fe8a2c30feb3fd7a327f8536f6 (patch) | |
tree | 9d223809ca349d9d58fbb3d5616aa095406f3f23 /src/Verismith/Result.hs | |
parent | 37023ee30b7e3663c227dd56a6f4b4f0e004f7cb (diff) | |
download | verismith-ff5065834a9dc8fe8a2c30feb3fd7a327f8536f6.tar.gz verismith-ff5065834a9dc8fe8a2c30feb3fd7a327f8536f6.zip |
Add configuration for default Yosys location
Diffstat (limited to 'src/Verismith/Result.hs')
-rw-r--r-- | src/Verismith/Result.hs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/Verismith/Result.hs b/src/Verismith/Result.hs index 2ecb728..78c8dd6 100644 --- a/src/Verismith/Result.hs +++ b/src/Verismith/Result.hs @@ -29,13 +29,15 @@ module Verismith.Result ) where +import Control.Monad (liftM) import Control.Monad.Base import Control.Monad.IO.Class import Control.Monad.Trans.Class import Control.Monad.Trans.Control import Data.Bifunctor (Bifunctor (..)) import Shelly (RunFailed (..), Sh, catch_sh) -import Shelly.Lifted (MonadSh, liftSh) +import Shelly.Lifted (MonadSh, MonadShControl, ShM, + liftSh, liftShWith, restoreSh) -- | Result type which is equivalent to 'Either' or 'Error'. This is -- reimplemented so that there is full control over the 'Monad' definition and @@ -134,6 +136,16 @@ instance MonadBaseControl IO m => MonadBaseControl IO (ResultT a m) where {-# INLINABLE liftBaseWith #-} {-# INLINABLE restoreM #-} +instance (MonadShControl m) + => MonadShControl (ResultT a m) where + newtype ShM (ResultT a m) b = ResultTShM (ShM m (Result a b)) + liftShWith f = + ResultT $ liftM return $ liftShWith $ \runInSh -> f $ \k -> + liftM ResultTShM $ runInSh $ runResultT k + restoreSh (ResultTShM m) = ResultT . restoreSh $ m + {-# INLINE liftShWith #-} + {-# INLINE restoreSh #-} + infix 0 <?> (<?>) :: (Monad m, Monoid a) => ResultT a m b -> a -> ResultT a m b |