From 4a76ecedccd80f16eca38be05b256bcedd3d6b65 Mon Sep 17 00:00:00 2001 From: Michael Walker Date: Fri, 14 Aug 2015 15:20:03 +0100 Subject: [PATCH] Add Applicative constraint to classes for pre-AMP GHC --- Control/Monad/Conc/Class.hs | 4 +++- Control/Monad/STM/Class.hs | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Control/Monad/Conc/Class.hs b/Control/Monad/Conc/Class.hs index 8a77891..c43feac 100755 --- a/Control/Monad/Conc/Class.hs +++ b/Control/Monad/Conc/Class.hs @@ -12,6 +12,7 @@ module Control.Monad.Conc.Class , killThread ) where +import Control.Applicative (Applicative) import Control.Concurrent (forkIO) import Control.Concurrent.MVar (MVar, readMVar, newEmptyMVar, putMVar, tryPutMVar, takeMVar, tryTakeMVar) import Control.Exception (Exception, AsyncException(ThreadKilled), SomeException) @@ -51,7 +52,8 @@ import qualified Control.Monad.Writer.Strict as WS -- -- Every @MonadConc@ has an associated 'MonadSTM', transactions of -- which can be run atomically. -class ( Monad m, MonadCatch m, MonadThrow m, MonadMask m +class ( Applicative m, Monad m + , MonadCatch m, MonadThrow m, MonadMask m , MonadSTM (STMLike m) , Eq (ThreadId m), Show (ThreadId m)) => MonadConc m where -- | The associated 'MonadSTM' for this class. diff --git a/Control/Monad/STM/Class.hs b/Control/Monad/STM/Class.hs index 01a50c3..ac4790a 100755 --- a/Control/Monad/STM/Class.hs +++ b/Control/Monad/STM/Class.hs @@ -4,6 +4,7 @@ -- with 'MonadConc'. module Control.Monad.STM.Class where +import Control.Applicative (Applicative) import Control.Concurrent.STM (STM) import Control.Concurrent.STM.TVar (TVar, newTVar, readTVar, writeTVar) import Control.Exception (Exception) @@ -30,7 +31,7 @@ import qualified Control.Monad.Writer.Strict as WS -- -- A minimal implementation consists of 'retry', 'orElse', 'newCTVar', -- 'readCTVar', and 'writeCTVar'. -class (Monad m, MonadCatch m, MonadThrow m) => MonadSTM m where +class (Applicative m, Monad m, MonadCatch m, MonadThrow m) => MonadSTM m where -- | The mutable reference type. These behave like 'TVar's, in that -- they always contain a value and updates are non-blocking and -- synchronised.