mirror of
https://github.com/barrucadu/dejafu.git
synced 2024-12-18 11:01:50 +03:00
Add missing MonadFail instances (when base >=4.9) for ConcT/STM
Closes #136
This commit is contained in:
parent
a0801d65eb
commit
e9a64a1f8d
@ -14,6 +14,14 @@ unreleased
|
||||
|
||||
- Fix some incorrect "@since" haddock comments.
|
||||
|
||||
### Test.DejaFu.Conc
|
||||
|
||||
- Add a missing `MonadFail` instance.
|
||||
|
||||
### Test.DejaFu.STM
|
||||
|
||||
- Add a missing `MonadFail` instance.
|
||||
|
||||
|
||||
---------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
{-# LANGUAGE CPP #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
@ -11,7 +12,7 @@
|
||||
-- License : MIT
|
||||
-- Maintainer : Michael Walker <mike@barrucadu.co.uk>
|
||||
-- Stability : experimental
|
||||
-- Portability : FlexibleInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, RankNTypes, TypeFamilies, TypeSynonymInstances
|
||||
-- Portability : CPP, FlexibleInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, RankNTypes, TypeFamilies, TypeSynonymInstances
|
||||
--
|
||||
-- Deterministic traced execution of concurrent computations.
|
||||
--
|
||||
@ -65,9 +66,19 @@ import Test.DejaFu.Conc.Internal
|
||||
import Test.DejaFu.Conc.Internal.Common
|
||||
import Test.DejaFu.STM
|
||||
|
||||
#if MIN_VERSION_base(4,9,0)
|
||||
import qualified Control.Monad.Fail as Fail
|
||||
#endif
|
||||
|
||||
-- | @since 0.6.0.0
|
||||
newtype ConcT r n a = C { unC :: M n r a } deriving (Functor, Applicative, Monad)
|
||||
|
||||
#if MIN_VERSION_base(4,9,0)
|
||||
-- | @since unreleased
|
||||
instance Fail.MonadFail (ConcT r n) where
|
||||
fail = C . fail
|
||||
#endif
|
||||
|
||||
-- | A 'MonadConc' implementation using @ST@, this should be preferred
|
||||
-- if you do not need 'liftIO'.
|
||||
--
|
||||
|
@ -39,9 +39,19 @@ import qualified Control.Monad.STM.Class as C
|
||||
import Test.DejaFu.Common
|
||||
import Test.DejaFu.STM.Internal
|
||||
|
||||
#if MIN_VERSION_base(4,9,0)
|
||||
import qualified Control.Monad.Fail as Fail
|
||||
#endif
|
||||
|
||||
-- | @since 0.3.0.0
|
||||
newtype STMLike n r a = S { runSTM :: M n r a } deriving (Functor, Applicative, Monad)
|
||||
|
||||
#if MIN_VERSION_base(4,9,0)
|
||||
-- | @since unreleased
|
||||
instance Fail.MonadFail (STMLike r n) where
|
||||
fail = S . fail
|
||||
#endif
|
||||
|
||||
-- | Create a new STM continuation.
|
||||
toSTM :: ((a -> STMAction n r) -> STMAction n r) -> STMLike n r a
|
||||
toSTM = S . cont
|
||||
|
Loading…
Reference in New Issue
Block a user