mirror of
https://github.com/unisonweb/unison.git
synced 2024-11-13 00:12:21 +03:00
MonadCatch and MonadThrow instances for Test
This commit is contained in:
parent
844deaa9c1
commit
8d05785c30
@ -58,6 +58,7 @@ library
|
||||
build-depends:
|
||||
async >= 2.1.1,
|
||||
base >= 4.3,
|
||||
exceptions,
|
||||
mtl >= 2.0.1,
|
||||
containers >= 0.4.0,
|
||||
stm >= 2.4,
|
||||
|
@ -9,6 +9,8 @@ import Control.Concurrent
|
||||
import Control.Concurrent.STM
|
||||
import Control.Exception
|
||||
import Control.Monad
|
||||
import Control.Monad.Catch (MonadCatch, MonadThrow(throwM))
|
||||
import qualified Control.Monad.Catch as Catch
|
||||
import Control.Monad.IO.Class
|
||||
import Control.Monad.Reader
|
||||
import Data.List
|
||||
@ -404,6 +406,13 @@ instance Monad Test where
|
||||
instance MonadFail Test where
|
||||
fail = crash
|
||||
|
||||
instance MonadThrow Test where
|
||||
throwM = Test . throwM
|
||||
|
||||
instance MonadCatch Test where
|
||||
catch (Test m) f =
|
||||
Test $ Catch.catch m (\e -> case f e of Test m' -> m')
|
||||
|
||||
instance Functor Test where
|
||||
fmap = liftM
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user