{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
module Control.Monad.Conc.Class
( MonadConc(..)
, fork
, forkOn
, forkOS
, forkFinally
, spawn
, killThread
, rtsSupportsBoundThreads
, runInBoundThread
, runInUnboundThread
, forkN
, forkOnN
, forkOSN
, throw
, catch
, mask
, Ca.mask_
, uninterruptibleMask
, Ca.uninterruptibleMask_
, interruptible
, newMVar
, newMVarN
, cas
, peekTicket
, IsConc
, toIsConc
, fromIsConc
, liftedF
, liftedFork
) where
import Control.Exception (AsyncException(ThreadKilled),
Exception, MaskingState(..),
SomeException)
import Control.Monad.Catch (MonadCatch, MonadMask,
MonadThrow)
import qualified Control.Monad.Catch as Ca
import Control.Monad.Fail (MonadFail(..))
import Control.Monad.STM.Class (IsSTM, MonadSTM, TVar, fromIsSTM,
newTVar, readTVar)
import Control.Monad.Trans.Control (MonadTransControl, StT, liftWith)
import Data.Kind (Type)
import Data.Proxy (Proxy(..))
import qualified Control.Concurrent as IO
import qualified Control.Concurrent.STM.TVar as IO
import qualified Control.Exception as IO
import qualified Control.Monad.STM as IO
import qualified Data.Atomics as IO
import qualified Data.IORef as IO
import qualified GHC.Conc as IO
import qualified GHC.IO as IO
import Control.Monad.Reader (ReaderT)
import qualified Control.Monad.RWS.Lazy as RL
import qualified Control.Monad.RWS.Strict as RS
import qualified Control.Monad.State.Lazy as SL
import qualified Control.Monad.State.Strict as SS
import Control.Monad.Trans (lift)
import Control.Monad.Trans.Identity (IdentityT)
import qualified Control.Monad.Writer.Lazy as WL
import qualified Control.Monad.Writer.Strict as WS
class ( Monad m
, MonadCatch m, MonadThrow m, MonadMask m
, MonadSTM (STM m)
, Ord (ThreadId m), Show (ThreadId m)) => MonadConc m where
{-# MINIMAL
(forkWithUnmask | forkWithUnmaskN)
, (forkOnWithUnmask | forkOnWithUnmaskN)
, (forkOSWithUnmask | forkOSWithUnmaskN)
, supportsBoundThreads
, isCurrentThreadBound
, getNumCapabilities
, setNumCapabilities
, myThreadId
, yield
, (newEmptyMVar | newEmptyMVarN)
, putMVar
, tryPutMVar
, readMVar
, tryReadMVar
, takeMVar
, tryTakeMVar
, (newIORef | newIORefN)
, atomicModifyIORef
, writeIORef
, readForCAS
, peekTicket'
, casIORef
, modifyIORefCAS
, atomically
, throwTo
, getMaskingState
, unsafeUnmask
#-}
type STM m :: Type -> Type
type MVar m :: Type -> Type
type IORef m :: Type -> Type
type Ticket m :: Type -> Type
type ThreadId m :: Type
forkWithUnmask :: ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkWithUnmask = String -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forall (m :: * -> *).
MonadConc m =>
String -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkWithUnmaskN String
""
forkWithUnmaskN :: String -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkWithUnmaskN String
_ = ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forall (m :: * -> *).
MonadConc m =>
((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkWithUnmask
forkOnWithUnmask :: Int -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkOnWithUnmask = String -> Int -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forall (m :: * -> *).
MonadConc m =>
String -> Int -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkOnWithUnmaskN String
""
forkOnWithUnmaskN :: String -> Int -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkOnWithUnmaskN String
_ = Int -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forall (m :: * -> *).
MonadConc m =>
Int -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkOnWithUnmask
forkOSWithUnmask :: ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkOSWithUnmask = String -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forall (m :: * -> *).
MonadConc m =>
String -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkOSWithUnmaskN String
""
forkOSWithUnmaskN :: String -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkOSWithUnmaskN String
_ = ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forall (m :: * -> *).
MonadConc m =>
((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkOSWithUnmask
supportsBoundThreads :: m Bool
isCurrentThreadBound :: m Bool
getNumCapabilities :: m Int
setNumCapabilities :: Int -> m ()
myThreadId :: m (ThreadId m)
yield :: m ()
threadDelay :: Int -> m ()
threadDelay Int
_ = m ()
forall (m :: * -> *). MonadConc m => m ()
yield
newEmptyMVar :: m (MVar m a)
newEmptyMVar = String -> m (MVar m a)
forall (m :: * -> *) a. MonadConc m => String -> m (MVar m a)
newEmptyMVarN String
""
newEmptyMVarN :: String -> m (MVar m a)
newEmptyMVarN String
_ = m (MVar m a)
forall (m :: * -> *) a. MonadConc m => m (MVar m a)
newEmptyMVar
putMVar :: MVar m a -> a -> m ()
tryPutMVar :: MVar m a -> a -> m Bool
readMVar :: MVar m a -> m a
tryReadMVar :: MVar m a -> m (Maybe a)
takeMVar :: MVar m a -> m a
tryTakeMVar :: MVar m a -> m (Maybe a)
newIORef :: a -> m (IORef m a)
newIORef = String -> a -> m (IORef m a)
forall (m :: * -> *) a. MonadConc m => String -> a -> m (IORef m a)
newIORefN String
""
newIORefN :: String -> a -> m (IORef m a)
newIORefN String
_ = a -> m (IORef m a)
forall (m :: * -> *) a. MonadConc m => a -> m (IORef m a)
newIORef
readIORef :: IORef m a -> m a
readIORef IORef m a
ioref = IORef m a -> m (Ticket m a)
forall (m :: * -> *) a. MonadConc m => IORef m a -> m (Ticket m a)
readForCAS IORef m a
ioref m (Ticket m a) -> (Ticket m a -> m a) -> m a
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Ticket m a -> m a
forall (m :: * -> *) a. MonadConc m => Ticket m a -> m a
peekTicket
atomicModifyIORef :: IORef m a -> (a -> (a, b)) -> m b
writeIORef :: IORef m a -> a -> m ()
atomicWriteIORef :: IORef m a -> a -> m ()
atomicWriteIORef IORef m a
r a
a = IORef m a -> (a -> (a, ())) -> m ()
forall (m :: * -> *) a b.
MonadConc m =>
IORef m a -> (a -> (a, b)) -> m b
atomicModifyIORef IORef m a
r ((a -> (a, ())) -> m ()) -> (a -> (a, ())) -> m ()
forall a b. (a -> b) -> a -> b
$ (a, ()) -> a -> (a, ())
forall a b. a -> b -> a
const (a
a, ())
readForCAS :: IORef m a -> m (Ticket m a)
peekTicket' :: Proxy m -> Ticket m a -> a
casIORef :: IORef m a -> Ticket m a -> a -> m (Bool, Ticket m a)
modifyIORefCAS :: IORef m a -> (a -> (a, b)) -> m b
modifyIORefCAS_ :: IORef m a -> (a -> a) -> m ()
modifyIORefCAS_ IORef m a
ioref a -> a
f = IORef m a -> (a -> (a, ())) -> m ()
forall (m :: * -> *) a b.
MonadConc m =>
IORef m a -> (a -> (a, b)) -> m b
modifyIORefCAS IORef m a
ioref (\a
a -> (a -> a
f a
a, ()))
atomically :: STM m a -> m a
newTVarConc :: a -> m (TVar (STM m) a)
newTVarConc = STM m (TVar (STM m) a) -> m (TVar (STM m) a)
forall (m :: * -> *) a. MonadConc m => STM m a -> m a
atomically (STM m (TVar (STM m) a) -> m (TVar (STM m) a))
-> (a -> STM m (TVar (STM m) a)) -> a -> m (TVar (STM m) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> STM m (TVar (STM m) a)
forall (stm :: * -> *) a. MonadSTM stm => a -> stm (TVar stm a)
newTVar
readTVarConc :: TVar (STM m) a -> m a
readTVarConc = STM m a -> m a
forall (m :: * -> *) a. MonadConc m => STM m a -> m a
atomically (STM m a -> m a)
-> (TVar (STM m) a -> STM m a) -> TVar (STM m) a -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TVar (STM m) a -> STM m a
forall (stm :: * -> *) a. MonadSTM stm => TVar stm a -> stm a
readTVar
throwTo :: Exception e => ThreadId m -> e -> m ()
getMaskingState :: m MaskingState
unsafeUnmask :: m a -> m a
fork :: MonadConc m => m () -> m (ThreadId m)
fork :: m () -> m (ThreadId m)
fork m ()
ma = ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forall (m :: * -> *).
MonadConc m =>
((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkWithUnmask (\forall a. m a -> m a
_ -> m ()
ma)
forkOn :: MonadConc m => Int -> m () -> m (ThreadId m)
forkOn :: Int -> m () -> m (ThreadId m)
forkOn Int
c m ()
ma = Int -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forall (m :: * -> *).
MonadConc m =>
Int -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkOnWithUnmask Int
c (\forall a. m a -> m a
_ -> m ()
ma)
forkOS :: MonadConc m => m () -> m (ThreadId m)
forkOS :: m () -> m (ThreadId m)
forkOS m ()
ma = ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forall (m :: * -> *).
MonadConc m =>
((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkOSWithUnmask (\forall a. m a -> m a
_ -> m ()
ma)
forkFinally :: MonadConc m => m a -> (Either SomeException a -> m ()) -> m (ThreadId m)
forkFinally :: m a -> (Either SomeException a -> m ()) -> m (ThreadId m)
forkFinally m a
action Either SomeException a -> m ()
and_then =
((forall a. m a -> m a) -> m (ThreadId m)) -> m (ThreadId m)
forall (m :: * -> *) b.
MonadConc m =>
((forall a. m a -> m a) -> m b) -> m b
mask (((forall a. m a -> m a) -> m (ThreadId m)) -> m (ThreadId m))
-> ((forall a. m a -> m a) -> m (ThreadId m)) -> m (ThreadId m)
forall a b. (a -> b) -> a -> b
$ \forall a. m a -> m a
restore ->
m () -> m (ThreadId m)
forall (m :: * -> *). MonadConc m => m () -> m (ThreadId m)
fork (m () -> m (ThreadId m)) -> m () -> m (ThreadId m)
forall a b. (a -> b) -> a -> b
$ m a -> m (Either SomeException a)
forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
m a -> m (Either e a)
Ca.try (m a -> m a
forall a. m a -> m a
restore m a
action) m (Either SomeException a)
-> (Either SomeException a -> m ()) -> m ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Either SomeException a -> m ()
and_then
spawn :: MonadConc m => m a -> m (MVar m a)
spawn :: m a -> m (MVar m a)
spawn m a
ma = do
MVar m a
cvar <- m (MVar m a)
forall (m :: * -> *) a. MonadConc m => m (MVar m a)
newEmptyMVar
ThreadId m
_ <- m () -> m (ThreadId m)
forall (m :: * -> *). MonadConc m => m () -> m (ThreadId m)
fork (m () -> m (ThreadId m)) -> m () -> m (ThreadId m)
forall a b. (a -> b) -> a -> b
$ m a
ma m a -> (a -> m ()) -> m ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= MVar m a -> a -> m ()
forall (m :: * -> *) a. MonadConc m => MVar m a -> a -> m ()
putMVar MVar m a
cvar
MVar m a -> m (MVar m a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure MVar m a
cvar
killThread :: MonadConc m => ThreadId m -> m ()
killThread :: ThreadId m -> m ()
killThread ThreadId m
tid = ThreadId m -> AsyncException -> m ()
forall (m :: * -> *) e.
(MonadConc m, Exception e) =>
ThreadId m -> e -> m ()
throwTo ThreadId m
tid AsyncException
ThreadKilled
forkN :: MonadConc m => String -> m () -> m (ThreadId m)
forkN :: String -> m () -> m (ThreadId m)
forkN String
name m ()
ma = String -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forall (m :: * -> *).
MonadConc m =>
String -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkWithUnmaskN String
name (\forall a. m a -> m a
_ -> m ()
ma)
forkOnN :: MonadConc m => String -> Int -> m () -> m (ThreadId m)
forkOnN :: String -> Int -> m () -> m (ThreadId m)
forkOnN String
name Int
i m ()
ma = String -> Int -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forall (m :: * -> *).
MonadConc m =>
String -> Int -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkOnWithUnmaskN String
name Int
i (\forall a. m a -> m a
_ -> m ()
ma)
forkOSN :: MonadConc m => String -> m () -> m (ThreadId m)
forkOSN :: String -> m () -> m (ThreadId m)
forkOSN String
name m ()
ma = String -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forall (m :: * -> *).
MonadConc m =>
String -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkOSWithUnmaskN String
name (\forall a. m a -> m a
_ -> m ()
ma)
{-# DEPRECATED rtsSupportsBoundThreads "Use 'supportsBoundThreads' instead" #-}
rtsSupportsBoundThreads :: Bool
rtsSupportsBoundThreads :: Bool
rtsSupportsBoundThreads = Bool
IO.rtsSupportsBoundThreads
runInBoundThread :: MonadConc m => m a -> m a
runInBoundThread :: m a -> m a
runInBoundThread =
m Bool -> (m () -> m (ThreadId m)) -> m a -> m a
forall (m :: * -> *) a.
MonadConc m =>
m Bool -> (m () -> m (ThreadId m)) -> m a -> m a
runInThread (Bool -> Bool
not (Bool -> Bool) -> m Bool -> m Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Bool
forall (m :: * -> *). MonadConc m => m Bool
isCurrentThreadBound) (String -> m () -> m (ThreadId m)
forall (m :: * -> *).
MonadConc m =>
String -> m () -> m (ThreadId m)
forkOSN String
"runInBoundThread")
runInUnboundThread :: MonadConc m => m a -> m a
runInUnboundThread :: m a -> m a
runInUnboundThread =
m Bool -> (m () -> m (ThreadId m)) -> m a -> m a
forall (m :: * -> *) a.
MonadConc m =>
m Bool -> (m () -> m (ThreadId m)) -> m a -> m a
runInThread m Bool
forall (m :: * -> *). MonadConc m => m Bool
isCurrentThreadBound (String -> m () -> m (ThreadId m)
forall (m :: * -> *).
MonadConc m =>
String -> m () -> m (ThreadId m)
forkN String
"runInUnboundThread")
runInThread :: MonadConc m => m Bool -> (m () -> m (ThreadId m)) -> m a -> m a
runInThread :: m Bool -> (m () -> m (ThreadId m)) -> m a -> m a
runInThread m Bool
check m () -> m (ThreadId m)
dofork m a
action = do
Bool
flag <- m Bool
check
if Bool
flag
then do
MVar m (Either SomeException a)
mv <- m (MVar m (Either SomeException a))
forall (m :: * -> *) a. MonadConc m => m (MVar m a)
newEmptyMVar
((forall a. m a -> m a) -> m a) -> m a
forall (m :: * -> *) b.
MonadConc m =>
((forall a. m a -> m a) -> m b) -> m b
mask (((forall a. m a -> m a) -> m a) -> m a)
-> ((forall a. m a -> m a) -> m a) -> m a
forall a b. (a -> b) -> a -> b
$ \forall a. m a -> m a
restore -> do
ThreadId m
tid <- m () -> m (ThreadId m)
dofork (m () -> m (ThreadId m)) -> m () -> m (ThreadId m)
forall a b. (a -> b) -> a -> b
$ m a -> m (Either SomeException a)
forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
m a -> m (Either e a)
Ca.try (m a -> m a
forall a. m a -> m a
restore m a
action) m (Either SomeException a)
-> (Either SomeException a -> m ()) -> m ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= MVar m (Either SomeException a) -> Either SomeException a -> m ()
forall (m :: * -> *) a. MonadConc m => MVar m a -> a -> m ()
putMVar MVar m (Either SomeException a)
mv
let wait :: m (Either SomeException a)
wait = MVar m (Either SomeException a) -> m (Either SomeException a)
forall (m :: * -> *) a. MonadConc m => MVar m a -> m a
takeMVar MVar m (Either SomeException a)
mv m (Either SomeException a)
-> (SomeException -> m (Either SomeException a))
-> m (Either SomeException a)
forall (m :: * -> *) e a.
(MonadConc m, Exception e) =>
m a -> (e -> m a) -> m a
`catch` \(SomeException
e :: SomeException) -> ThreadId m -> SomeException -> m ()
forall (m :: * -> *) e.
(MonadConc m, Exception e) =>
ThreadId m -> e -> m ()
throwTo ThreadId m
tid SomeException
e m () -> m (Either SomeException a) -> m (Either SomeException a)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> m (Either SomeException a)
wait
m (Either SomeException a)
wait m (Either SomeException a)
-> (Either SomeException a -> m a) -> m a
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (SomeException -> m a)
-> (a -> m a) -> Either SomeException a -> m a
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (\(SomeException
e :: SomeException) -> SomeException -> m a
forall (m :: * -> *) e a. (MonadConc m, Exception e) => e -> m a
throw SomeException
e) a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
else m a
action
throw :: (MonadConc m, Exception e) => e -> m a
throw :: e -> m a
throw = e -> m a
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
Ca.throwM
catch :: (MonadConc m, Exception e) => m a -> (e -> m a) -> m a
catch :: m a -> (e -> m a) -> m a
catch = m a -> (e -> m a) -> m a
forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
m a -> (e -> m a) -> m a
Ca.catch
mask :: MonadConc m => ((forall a. m a -> m a) -> m b) -> m b
mask :: ((forall a. m a -> m a) -> m b) -> m b
mask = ((forall a. m a -> m a) -> m b) -> m b
forall (m :: * -> *) b.
MonadMask m =>
((forall a. m a -> m a) -> m b) -> m b
Ca.mask
uninterruptibleMask :: MonadConc m => ((forall a. m a -> m a) -> m b) -> m b
uninterruptibleMask :: ((forall a. m a -> m a) -> m b) -> m b
uninterruptibleMask = ((forall a. m a -> m a) -> m b) -> m b
forall (m :: * -> *) b.
MonadMask m =>
((forall a. m a -> m a) -> m b) -> m b
Ca.uninterruptibleMask
interruptible :: MonadConc m => m a -> m a
interruptible :: m a -> m a
interruptible m a
act = do
MaskingState
st <- m MaskingState
forall (m :: * -> *). MonadConc m => m MaskingState
getMaskingState
case MaskingState
st of
MaskingState
Unmasked -> m a
act
MaskingState
MaskedInterruptible -> m a -> m a
forall (m :: * -> *) a. MonadConc m => m a -> m a
unsafeUnmask m a
act
MaskingState
MaskedUninterruptible -> m a
act
newMVar :: MonadConc m => a -> m (MVar m a)
newMVar :: a -> m (MVar m a)
newMVar a
a = do
MVar m a
cvar <- m (MVar m a)
forall (m :: * -> *) a. MonadConc m => m (MVar m a)
newEmptyMVar
MVar m a -> a -> m ()
forall (m :: * -> *) a. MonadConc m => MVar m a -> a -> m ()
putMVar MVar m a
cvar a
a
MVar m a -> m (MVar m a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure MVar m a
cvar
newMVarN :: MonadConc m => String -> a -> m (MVar m a)
newMVarN :: String -> a -> m (MVar m a)
newMVarN String
n a
a = do
MVar m a
cvar <- String -> m (MVar m a)
forall (m :: * -> *) a. MonadConc m => String -> m (MVar m a)
newEmptyMVarN String
n
MVar m a -> a -> m ()
forall (m :: * -> *) a. MonadConc m => MVar m a -> a -> m ()
putMVar MVar m a
cvar a
a
MVar m a -> m (MVar m a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure MVar m a
cvar
peekTicket :: forall m a. MonadConc m => Ticket m a -> m a
peekTicket :: Ticket m a -> m a
peekTicket Ticket m a
t = a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a -> m a) -> a -> m a
forall a b. (a -> b) -> a -> b
$ Proxy m -> Ticket m a -> a
forall (m :: * -> *) a. MonadConc m => Proxy m -> Ticket m a -> a
peekTicket' (Proxy m
forall k (t :: k). Proxy t
Proxy :: Proxy m) (Ticket m a
t :: Ticket m a)
cas :: MonadConc m => IORef m a -> a -> m (Bool, a)
cas :: IORef m a -> a -> m (Bool, a)
cas IORef m a
ioref a
a = do
Ticket m a
tick <- IORef m a -> m (Ticket m a)
forall (m :: * -> *) a. MonadConc m => IORef m a -> m (Ticket m a)
readForCAS IORef m a
ioref
(Bool
suc, Ticket m a
tick') <- IORef m a -> Ticket m a -> a -> m (Bool, Ticket m a)
forall (m :: * -> *) a.
MonadConc m =>
IORef m a -> Ticket m a -> a -> m (Bool, Ticket m a)
casIORef IORef m a
ioref Ticket m a
tick a
a
a
a' <- Ticket m a -> m a
forall (m :: * -> *) a. MonadConc m => Ticket m a -> m a
peekTicket Ticket m a
tick'
(Bool, a) -> m (Bool, a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Bool
suc, a
a')
instance MonadConc IO where
type STM IO = IO.STM
type MVar IO = IO.MVar
type IORef IO = IO.IORef
type Ticket IO = IO.Ticket
type ThreadId IO = IO.ThreadId
forkWithUnmask :: ((forall a. IO a -> IO a) -> IO ()) -> IO (ThreadId IO)
forkWithUnmask = ((forall a. IO a -> IO a) -> IO ()) -> IO ThreadId
((forall a. IO a -> IO a) -> IO ()) -> IO (ThreadId IO)
IO.forkIOWithUnmask
forkOnWithUnmask :: Int -> ((forall a. IO a -> IO a) -> IO ()) -> IO (ThreadId IO)
forkOnWithUnmask = Int -> ((forall a. IO a -> IO a) -> IO ()) -> IO ThreadId
Int -> ((forall a. IO a -> IO a) -> IO ()) -> IO (ThreadId IO)
IO.forkOnWithUnmask
forkOSWithUnmask :: ((forall a. IO a -> IO a) -> IO ()) -> IO (ThreadId IO)
forkOSWithUnmask = ((forall a. IO a -> IO a) -> IO ()) -> IO ThreadId
((forall a. IO a -> IO a) -> IO ()) -> IO (ThreadId IO)
IO.forkOSWithUnmask
forkWithUnmaskN :: String -> ((forall a. IO a -> IO a) -> IO ()) -> IO (ThreadId IO)
forkWithUnmaskN String
n (forall a. IO a -> IO a) -> IO ()
ma = ((forall a. IO a -> IO a) -> IO ()) -> IO (ThreadId IO)
forall (m :: * -> *).
MonadConc m =>
((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkWithUnmask (((forall a. IO a -> IO a) -> IO ()) -> IO (ThreadId IO))
-> ((forall a. IO a -> IO a) -> IO ()) -> IO (ThreadId IO)
forall a b. (a -> b) -> a -> b
$ \forall a. IO a -> IO a
umask -> do
String -> IO ()
labelMe String
n
(forall a. IO a -> IO a) -> IO ()
ma forall a. IO a -> IO a
umask
forkOnWithUnmaskN :: String
-> Int -> ((forall a. IO a -> IO a) -> IO ()) -> IO (ThreadId IO)
forkOnWithUnmaskN String
n Int
i (forall a. IO a -> IO a) -> IO ()
ma = Int -> ((forall a. IO a -> IO a) -> IO ()) -> IO (ThreadId IO)
forall (m :: * -> *).
MonadConc m =>
Int -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkOnWithUnmask Int
i (((forall a. IO a -> IO a) -> IO ()) -> IO (ThreadId IO))
-> ((forall a. IO a -> IO a) -> IO ()) -> IO (ThreadId IO)
forall a b. (a -> b) -> a -> b
$ \forall a. IO a -> IO a
umask -> do
String -> IO ()
labelMe String
n
(forall a. IO a -> IO a) -> IO ()
ma forall a. IO a -> IO a
umask
forkOSWithUnmaskN :: String -> ((forall a. IO a -> IO a) -> IO ()) -> IO (ThreadId IO)
forkOSWithUnmaskN String
n (forall a. IO a -> IO a) -> IO ()
ma = ((forall a. IO a -> IO a) -> IO ()) -> IO (ThreadId IO)
forall (m :: * -> *).
MonadConc m =>
((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkOSWithUnmask (((forall a. IO a -> IO a) -> IO ()) -> IO (ThreadId IO))
-> ((forall a. IO a -> IO a) -> IO ()) -> IO (ThreadId IO)
forall a b. (a -> b) -> a -> b
$ \forall a. IO a -> IO a
umask -> do
String -> IO ()
labelMe String
n
(forall a. IO a -> IO a) -> IO ()
ma forall a. IO a -> IO a
umask
supportsBoundThreads :: IO Bool
supportsBoundThreads = Bool -> IO Bool
forall (f :: * -> *) a. Applicative f => a -> f a
pure Bool
IO.rtsSupportsBoundThreads
isCurrentThreadBound :: IO Bool
isCurrentThreadBound = IO Bool
IO.isCurrentThreadBound
getNumCapabilities :: IO Int
getNumCapabilities = IO Int
IO.getNumCapabilities
setNumCapabilities :: Int -> IO ()
setNumCapabilities = Int -> IO ()
IO.setNumCapabilities
readMVar :: MVar IO a -> IO a
readMVar = MVar IO a -> IO a
forall a. MVar a -> IO a
IO.readMVar
tryReadMVar :: MVar IO a -> IO (Maybe a)
tryReadMVar = MVar IO a -> IO (Maybe a)
forall a. MVar a -> IO (Maybe a)
IO.tryReadMVar
myThreadId :: IO (ThreadId IO)
myThreadId = IO ThreadId
IO (ThreadId IO)
IO.myThreadId
yield :: IO ()
yield = IO ()
IO.yield
threadDelay :: Int -> IO ()
threadDelay = Int -> IO ()
IO.threadDelay
throwTo :: ThreadId IO -> e -> IO ()
throwTo = ThreadId IO -> e -> IO ()
forall e. Exception e => ThreadId -> e -> IO ()
IO.throwTo
newEmptyMVar :: IO (MVar IO a)
newEmptyMVar = IO (MVar IO a)
forall a. IO (MVar a)
IO.newEmptyMVar
putMVar :: MVar IO a -> a -> IO ()
putMVar = MVar IO a -> a -> IO ()
forall a. MVar a -> a -> IO ()
IO.putMVar
tryPutMVar :: MVar IO a -> a -> IO Bool
tryPutMVar = MVar IO a -> a -> IO Bool
forall a. MVar a -> a -> IO Bool
IO.tryPutMVar
takeMVar :: MVar IO a -> IO a
takeMVar = MVar IO a -> IO a
forall a. MVar a -> IO a
IO.takeMVar
tryTakeMVar :: MVar IO a -> IO (Maybe a)
tryTakeMVar = MVar IO a -> IO (Maybe a)
forall a. MVar a -> IO (Maybe a)
IO.tryTakeMVar
newIORef :: a -> IO (IORef IO a)
newIORef = a -> IO (IORef IO a)
forall a. a -> IO (IORef a)
IO.newIORef
readIORef :: IORef IO a -> IO a
readIORef = IORef IO a -> IO a
forall a. IORef a -> IO a
IO.readIORef
atomicModifyIORef :: IORef IO a -> (a -> (a, b)) -> IO b
atomicModifyIORef = IORef IO a -> (a -> (a, b)) -> IO b
forall a b. IORef a -> (a -> (a, b)) -> IO b
IO.atomicModifyIORef
writeIORef :: IORef IO a -> a -> IO ()
writeIORef = IORef IO a -> a -> IO ()
forall a. IORef a -> a -> IO ()
IO.writeIORef
atomicWriteIORef :: IORef IO a -> a -> IO ()
atomicWriteIORef = IORef IO a -> a -> IO ()
forall a. IORef a -> a -> IO ()
IO.atomicWriteIORef
readForCAS :: IORef IO a -> IO (Ticket IO a)
readForCAS = IORef IO a -> IO (Ticket IO a)
forall a. IORef a -> IO (Ticket a)
IO.readForCAS
peekTicket' :: Proxy IO -> Ticket IO a -> a
peekTicket' Proxy IO
_ = Ticket IO a -> a
forall a. Ticket a -> a
IO.peekTicket
casIORef :: IORef IO a -> Ticket IO a -> a -> IO (Bool, Ticket IO a)
casIORef = IORef IO a -> Ticket IO a -> a -> IO (Bool, Ticket IO a)
forall a. IORef a -> Ticket a -> a -> IO (Bool, Ticket a)
IO.casIORef
modifyIORefCAS :: IORef IO a -> (a -> (a, b)) -> IO b
modifyIORefCAS = IORef IO a -> (a -> (a, b)) -> IO b
forall a b. IORef a -> (a -> (a, b)) -> IO b
IO.atomicModifyIORefCAS
atomically :: STM IO a -> IO a
atomically = STM IO a -> IO a
forall a. STM a -> IO a
IO.atomically
newTVarConc :: a -> IO (TVar (STM IO) a)
newTVarConc = a -> IO (TVar (STM IO) a)
forall a. a -> IO (TVar a)
IO.newTVarIO
readTVarConc :: TVar (STM IO) a -> IO a
readTVarConc = TVar (STM IO) a -> IO a
forall a. TVar a -> IO a
IO.readTVarIO
getMaskingState :: IO MaskingState
getMaskingState = IO MaskingState
IO.getMaskingState
unsafeUnmask :: IO a -> IO a
unsafeUnmask = IO a -> IO a
forall a. IO a -> IO a
IO.unsafeUnmask
labelMe :: String -> IO ()
labelMe :: String -> IO ()
labelMe String
"" = () -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
labelMe String
n = do
ThreadId
tid <- IO ThreadId
forall (m :: * -> *). MonadConc m => m (ThreadId m)
myThreadId
ThreadId -> String -> IO ()
IO.labelThread ThreadId
tid String
n
newtype IsConc m a = IsConc { IsConc m a -> m a
unIsConc :: m a }
deriving (a -> IsConc m b -> IsConc m a
(a -> b) -> IsConc m a -> IsConc m b
(forall a b. (a -> b) -> IsConc m a -> IsConc m b)
-> (forall a b. a -> IsConc m b -> IsConc m a)
-> Functor (IsConc m)
forall a b. a -> IsConc m b -> IsConc m a
forall a b. (a -> b) -> IsConc m a -> IsConc m b
forall (m :: * -> *) a b.
Functor m =>
a -> IsConc m b -> IsConc m a
forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> IsConc m a -> IsConc m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> IsConc m b -> IsConc m a
$c<$ :: forall (m :: * -> *) a b.
Functor m =>
a -> IsConc m b -> IsConc m a
fmap :: (a -> b) -> IsConc m a -> IsConc m b
$cfmap :: forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> IsConc m a -> IsConc m b
Functor, Functor (IsConc m)
a -> IsConc m a
Functor (IsConc m)
-> (forall a. a -> IsConc m a)
-> (forall a b. IsConc m (a -> b) -> IsConc m a -> IsConc m b)
-> (forall a b c.
(a -> b -> c) -> IsConc m a -> IsConc m b -> IsConc m c)
-> (forall a b. IsConc m a -> IsConc m b -> IsConc m b)
-> (forall a b. IsConc m a -> IsConc m b -> IsConc m a)
-> Applicative (IsConc m)
IsConc m a -> IsConc m b -> IsConc m b
IsConc m a -> IsConc m b -> IsConc m a
IsConc m (a -> b) -> IsConc m a -> IsConc m b
(a -> b -> c) -> IsConc m a -> IsConc m b -> IsConc m c
forall a. a -> IsConc m a
forall a b. IsConc m a -> IsConc m b -> IsConc m a
forall a b. IsConc m a -> IsConc m b -> IsConc m b
forall a b. IsConc m (a -> b) -> IsConc m a -> IsConc m b
forall a b c.
(a -> b -> c) -> IsConc m a -> IsConc m b -> IsConc m c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
forall (m :: * -> *). Applicative m => Functor (IsConc m)
forall (m :: * -> *) a. Applicative m => a -> IsConc m a
forall (m :: * -> *) a b.
Applicative m =>
IsConc m a -> IsConc m b -> IsConc m a
forall (m :: * -> *) a b.
Applicative m =>
IsConc m a -> IsConc m b -> IsConc m b
forall (m :: * -> *) a b.
Applicative m =>
IsConc m (a -> b) -> IsConc m a -> IsConc m b
forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c) -> IsConc m a -> IsConc m b -> IsConc m c
<* :: IsConc m a -> IsConc m b -> IsConc m a
$c<* :: forall (m :: * -> *) a b.
Applicative m =>
IsConc m a -> IsConc m b -> IsConc m a
*> :: IsConc m a -> IsConc m b -> IsConc m b
$c*> :: forall (m :: * -> *) a b.
Applicative m =>
IsConc m a -> IsConc m b -> IsConc m b
liftA2 :: (a -> b -> c) -> IsConc m a -> IsConc m b -> IsConc m c
$cliftA2 :: forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c) -> IsConc m a -> IsConc m b -> IsConc m c
<*> :: IsConc m (a -> b) -> IsConc m a -> IsConc m b
$c<*> :: forall (m :: * -> *) a b.
Applicative m =>
IsConc m (a -> b) -> IsConc m a -> IsConc m b
pure :: a -> IsConc m a
$cpure :: forall (m :: * -> *) a. Applicative m => a -> IsConc m a
$cp1Applicative :: forall (m :: * -> *). Applicative m => Functor (IsConc m)
Applicative, Applicative (IsConc m)
a -> IsConc m a
Applicative (IsConc m)
-> (forall a b. IsConc m a -> (a -> IsConc m b) -> IsConc m b)
-> (forall a b. IsConc m a -> IsConc m b -> IsConc m b)
-> (forall a. a -> IsConc m a)
-> Monad (IsConc m)
IsConc m a -> (a -> IsConc m b) -> IsConc m b
IsConc m a -> IsConc m b -> IsConc m b
forall a. a -> IsConc m a
forall a b. IsConc m a -> IsConc m b -> IsConc m b
forall a b. IsConc m a -> (a -> IsConc m b) -> IsConc m b
forall (m :: * -> *). Monad m => Applicative (IsConc m)
forall (m :: * -> *) a. Monad m => a -> IsConc m a
forall (m :: * -> *) a b.
Monad m =>
IsConc m a -> IsConc m b -> IsConc m b
forall (m :: * -> *) a b.
Monad m =>
IsConc m a -> (a -> IsConc m b) -> IsConc m b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: a -> IsConc m a
$creturn :: forall (m :: * -> *) a. Monad m => a -> IsConc m a
>> :: IsConc m a -> IsConc m b -> IsConc m b
$c>> :: forall (m :: * -> *) a b.
Monad m =>
IsConc m a -> IsConc m b -> IsConc m b
>>= :: IsConc m a -> (a -> IsConc m b) -> IsConc m b
$c>>= :: forall (m :: * -> *) a b.
Monad m =>
IsConc m a -> (a -> IsConc m b) -> IsConc m b
$cp1Monad :: forall (m :: * -> *). Monad m => Applicative (IsConc m)
Monad, Monad (IsConc m)
e -> IsConc m a
Monad (IsConc m)
-> (forall e a. Exception e => e -> IsConc m a)
-> MonadThrow (IsConc m)
forall e a. Exception e => e -> IsConc m a
forall (m :: * -> *).
Monad m -> (forall e a. Exception e => e -> m a) -> MonadThrow m
forall (m :: * -> *). MonadThrow m => Monad (IsConc m)
forall (m :: * -> *) e a.
(MonadThrow m, Exception e) =>
e -> IsConc m a
throwM :: e -> IsConc m a
$cthrowM :: forall (m :: * -> *) e a.
(MonadThrow m, Exception e) =>
e -> IsConc m a
$cp1MonadThrow :: forall (m :: * -> *). MonadThrow m => Monad (IsConc m)
MonadThrow, MonadThrow (IsConc m)
MonadThrow (IsConc m)
-> (forall e a.
Exception e =>
IsConc m a -> (e -> IsConc m a) -> IsConc m a)
-> MonadCatch (IsConc m)
IsConc m a -> (e -> IsConc m a) -> IsConc m a
forall e a.
Exception e =>
IsConc m a -> (e -> IsConc m a) -> IsConc m a
forall (m :: * -> *).
MonadThrow m
-> (forall e a. Exception e => m a -> (e -> m a) -> m a)
-> MonadCatch m
forall (m :: * -> *). MonadCatch m => MonadThrow (IsConc m)
forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
IsConc m a -> (e -> IsConc m a) -> IsConc m a
catch :: IsConc m a -> (e -> IsConc m a) -> IsConc m a
$ccatch :: forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
IsConc m a -> (e -> IsConc m a) -> IsConc m a
$cp1MonadCatch :: forall (m :: * -> *). MonadCatch m => MonadThrow (IsConc m)
MonadCatch, MonadCatch (IsConc m)
MonadCatch (IsConc m)
-> (forall b.
((forall a. IsConc m a -> IsConc m a) -> IsConc m b) -> IsConc m b)
-> (forall b.
((forall a. IsConc m a -> IsConc m a) -> IsConc m b) -> IsConc m b)
-> (forall a b c.
IsConc m a
-> (a -> ExitCase b -> IsConc m c)
-> (a -> IsConc m b)
-> IsConc m (b, c))
-> MonadMask (IsConc m)
IsConc m a
-> (a -> ExitCase b -> IsConc m c)
-> (a -> IsConc m b)
-> IsConc m (b, c)
((forall a. IsConc m a -> IsConc m a) -> IsConc m b) -> IsConc m b
((forall a. IsConc m a -> IsConc m a) -> IsConc m b) -> IsConc m b
forall b.
((forall a. IsConc m a -> IsConc m a) -> IsConc m b) -> IsConc m b
forall a b c.
IsConc m a
-> (a -> ExitCase b -> IsConc m c)
-> (a -> IsConc m b)
-> IsConc m (b, c)
forall (m :: * -> *).
MonadCatch m
-> (forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> (forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> (forall a b c.
m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c))
-> MonadMask m
forall (m :: * -> *). MonadMask m => MonadCatch (IsConc m)
forall (m :: * -> *) b.
MonadMask m =>
((forall a. IsConc m a -> IsConc m a) -> IsConc m b) -> IsConc m b
forall (m :: * -> *) a b c.
MonadMask m =>
IsConc m a
-> (a -> ExitCase b -> IsConc m c)
-> (a -> IsConc m b)
-> IsConc m (b, c)
generalBracket :: IsConc m a
-> (a -> ExitCase b -> IsConc m c)
-> (a -> IsConc m b)
-> IsConc m (b, c)
$cgeneralBracket :: forall (m :: * -> *) a b c.
MonadMask m =>
IsConc m a
-> (a -> ExitCase b -> IsConc m c)
-> (a -> IsConc m b)
-> IsConc m (b, c)
uninterruptibleMask :: ((forall a. IsConc m a -> IsConc m a) -> IsConc m b) -> IsConc m b
$cuninterruptibleMask :: forall (m :: * -> *) b.
MonadMask m =>
((forall a. IsConc m a -> IsConc m a) -> IsConc m b) -> IsConc m b
mask :: ((forall a. IsConc m a -> IsConc m a) -> IsConc m b) -> IsConc m b
$cmask :: forall (m :: * -> *) b.
MonadMask m =>
((forall a. IsConc m a -> IsConc m a) -> IsConc m b) -> IsConc m b
$cp1MonadMask :: forall (m :: * -> *). MonadMask m => MonadCatch (IsConc m)
MonadMask)
deriving instance MonadFail m => MonadFail (IsConc m)
toIsConc :: MonadConc m => m a -> IsConc m a
toIsConc :: m a -> IsConc m a
toIsConc = m a -> IsConc m a
forall k (m :: k -> *) (a :: k). m a -> IsConc m a
IsConc
fromIsConc :: MonadConc m => IsConc m a -> m a
fromIsConc :: IsConc m a -> m a
fromIsConc = IsConc m a -> m a
forall k (m :: k -> *) (a :: k). IsConc m a -> m a
unIsConc
instance MonadConc m => MonadConc (IsConc m) where
type STM (IsConc m) = IsSTM (STM m)
type MVar (IsConc m) = MVar m
type IORef (IsConc m) = IORef m
type Ticket (IsConc m) = Ticket m
type ThreadId (IsConc m) = ThreadId m
forkWithUnmask :: ((forall a. IsConc m a -> IsConc m a) -> IsConc m ())
-> IsConc m (ThreadId (IsConc m))
forkWithUnmask (forall a. IsConc m a -> IsConc m a) -> IsConc m ()
ma = m (ThreadId m) -> IsConc m (ThreadId m)
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forall (m :: * -> *).
MonadConc m =>
((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkWithUnmask (\forall a. m a -> m a
umask -> IsConc m () -> m ()
forall k (m :: k -> *) (a :: k). IsConc m a -> m a
unIsConc (IsConc m () -> m ()) -> IsConc m () -> m ()
forall a b. (a -> b) -> a -> b
$ (forall a. IsConc m a -> IsConc m a) -> IsConc m ()
ma (\IsConc m a
mx -> m a -> IsConc m a
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m a -> m a
forall a. m a -> m a
umask (m a -> m a) -> m a -> m a
forall a b. (a -> b) -> a -> b
$ IsConc m a -> m a
forall k (m :: k -> *) (a :: k). IsConc m a -> m a
unIsConc IsConc m a
mx))))
forkWithUnmaskN :: String
-> ((forall a. IsConc m a -> IsConc m a) -> IsConc m ())
-> IsConc m (ThreadId (IsConc m))
forkWithUnmaskN String
n (forall a. IsConc m a -> IsConc m a) -> IsConc m ()
ma = m (ThreadId m) -> IsConc m (ThreadId m)
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (String -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forall (m :: * -> *).
MonadConc m =>
String -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkWithUnmaskN String
n (\forall a. m a -> m a
umask -> IsConc m () -> m ()
forall k (m :: k -> *) (a :: k). IsConc m a -> m a
unIsConc (IsConc m () -> m ()) -> IsConc m () -> m ()
forall a b. (a -> b) -> a -> b
$ (forall a. IsConc m a -> IsConc m a) -> IsConc m ()
ma (\IsConc m a
mx -> m a -> IsConc m a
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m a -> m a
forall a. m a -> m a
umask (m a -> m a) -> m a -> m a
forall a b. (a -> b) -> a -> b
$ IsConc m a -> m a
forall k (m :: k -> *) (a :: k). IsConc m a -> m a
unIsConc IsConc m a
mx))))
forkOnWithUnmask :: Int
-> ((forall a. IsConc m a -> IsConc m a) -> IsConc m ())
-> IsConc m (ThreadId (IsConc m))
forkOnWithUnmask Int
i (forall a. IsConc m a -> IsConc m a) -> IsConc m ()
ma = m (ThreadId m) -> IsConc m (ThreadId m)
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (Int -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forall (m :: * -> *).
MonadConc m =>
Int -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkOnWithUnmask Int
i (\forall a. m a -> m a
umask -> IsConc m () -> m ()
forall k (m :: k -> *) (a :: k). IsConc m a -> m a
unIsConc (IsConc m () -> m ()) -> IsConc m () -> m ()
forall a b. (a -> b) -> a -> b
$ (forall a. IsConc m a -> IsConc m a) -> IsConc m ()
ma (\IsConc m a
mx -> m a -> IsConc m a
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m a -> m a
forall a. m a -> m a
umask (m a -> m a) -> m a -> m a
forall a b. (a -> b) -> a -> b
$ IsConc m a -> m a
forall k (m :: k -> *) (a :: k). IsConc m a -> m a
unIsConc IsConc m a
mx))))
forkOnWithUnmaskN :: String
-> Int
-> ((forall a. IsConc m a -> IsConc m a) -> IsConc m ())
-> IsConc m (ThreadId (IsConc m))
forkOnWithUnmaskN String
n Int
i (forall a. IsConc m a -> IsConc m a) -> IsConc m ()
ma = m (ThreadId m) -> IsConc m (ThreadId m)
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (String -> Int -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forall (m :: * -> *).
MonadConc m =>
String -> Int -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkOnWithUnmaskN String
n Int
i (\forall a. m a -> m a
umask -> IsConc m () -> m ()
forall k (m :: k -> *) (a :: k). IsConc m a -> m a
unIsConc (IsConc m () -> m ()) -> IsConc m () -> m ()
forall a b. (a -> b) -> a -> b
$ (forall a. IsConc m a -> IsConc m a) -> IsConc m ()
ma (\IsConc m a
mx -> m a -> IsConc m a
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m a -> m a
forall a. m a -> m a
umask (m a -> m a) -> m a -> m a
forall a b. (a -> b) -> a -> b
$ IsConc m a -> m a
forall k (m :: k -> *) (a :: k). IsConc m a -> m a
unIsConc IsConc m a
mx))))
forkOSWithUnmask :: ((forall a. IsConc m a -> IsConc m a) -> IsConc m ())
-> IsConc m (ThreadId (IsConc m))
forkOSWithUnmask (forall a. IsConc m a -> IsConc m a) -> IsConc m ()
ma = m (ThreadId m) -> IsConc m (ThreadId m)
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forall (m :: * -> *).
MonadConc m =>
((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkOSWithUnmask (\forall a. m a -> m a
umask -> IsConc m () -> m ()
forall k (m :: k -> *) (a :: k). IsConc m a -> m a
unIsConc (IsConc m () -> m ()) -> IsConc m () -> m ()
forall a b. (a -> b) -> a -> b
$ (forall a. IsConc m a -> IsConc m a) -> IsConc m ()
ma (\IsConc m a
mx -> m a -> IsConc m a
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m a -> m a
forall a. m a -> m a
umask (m a -> m a) -> m a -> m a
forall a b. (a -> b) -> a -> b
$ IsConc m a -> m a
forall k (m :: k -> *) (a :: k). IsConc m a -> m a
unIsConc IsConc m a
mx))))
forkOSWithUnmaskN :: String
-> ((forall a. IsConc m a -> IsConc m a) -> IsConc m ())
-> IsConc m (ThreadId (IsConc m))
forkOSWithUnmaskN String
n (forall a. IsConc m a -> IsConc m a) -> IsConc m ()
ma = m (ThreadId m) -> IsConc m (ThreadId m)
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (String -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forall (m :: * -> *).
MonadConc m =>
String -> ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
forkOSWithUnmaskN String
n (\forall a. m a -> m a
umask -> IsConc m () -> m ()
forall k (m :: k -> *) (a :: k). IsConc m a -> m a
unIsConc (IsConc m () -> m ()) -> IsConc m () -> m ()
forall a b. (a -> b) -> a -> b
$ (forall a. IsConc m a -> IsConc m a) -> IsConc m ()
ma (\IsConc m a
mx -> m a -> IsConc m a
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m a -> m a
forall a. m a -> m a
umask (m a -> m a) -> m a -> m a
forall a b. (a -> b) -> a -> b
$ IsConc m a -> m a
forall k (m :: k -> *) (a :: k). IsConc m a -> m a
unIsConc IsConc m a
mx))))
unsafeUnmask :: IsConc m a -> IsConc m a
unsafeUnmask IsConc m a
ma = m a -> IsConc m a
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m a -> m a
forall (m :: * -> *) a. MonadConc m => m a -> m a
unsafeUnmask (IsConc m a -> m a
forall k (m :: k -> *) (a :: k). IsConc m a -> m a
unIsConc IsConc m a
ma))
supportsBoundThreads :: IsConc m Bool
supportsBoundThreads = m Bool -> IsConc m Bool
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc m Bool
forall (m :: * -> *). MonadConc m => m Bool
supportsBoundThreads
isCurrentThreadBound :: IsConc m Bool
isCurrentThreadBound = m Bool -> IsConc m Bool
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc m Bool
forall (m :: * -> *). MonadConc m => m Bool
isCurrentThreadBound
getNumCapabilities :: IsConc m Int
getNumCapabilities = m Int -> IsConc m Int
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc m Int
forall (m :: * -> *). MonadConc m => m Int
getNumCapabilities
setNumCapabilities :: Int -> IsConc m ()
setNumCapabilities = m () -> IsConc m ()
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m () -> IsConc m ()) -> (Int -> m ()) -> Int -> IsConc m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> m ()
forall (m :: * -> *). MonadConc m => Int -> m ()
setNumCapabilities
myThreadId :: IsConc m (ThreadId (IsConc m))
myThreadId = m (ThreadId m) -> IsConc m (ThreadId m)
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc m (ThreadId m)
forall (m :: * -> *). MonadConc m => m (ThreadId m)
myThreadId
yield :: IsConc m ()
yield = m () -> IsConc m ()
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc m ()
forall (m :: * -> *). MonadConc m => m ()
yield
threadDelay :: Int -> IsConc m ()
threadDelay = m () -> IsConc m ()
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m () -> IsConc m ()) -> (Int -> m ()) -> Int -> IsConc m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> m ()
forall (m :: * -> *). MonadConc m => Int -> m ()
threadDelay
throwTo :: ThreadId (IsConc m) -> e -> IsConc m ()
throwTo ThreadId (IsConc m)
t = m () -> IsConc m ()
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m () -> IsConc m ()) -> (e -> m ()) -> e -> IsConc m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ThreadId m -> e -> m ()
forall (m :: * -> *) e.
(MonadConc m, Exception e) =>
ThreadId m -> e -> m ()
throwTo ThreadId m
ThreadId (IsConc m)
t
newEmptyMVar :: IsConc m (MVar (IsConc m) a)
newEmptyMVar = m (MVar m a) -> IsConc m (MVar m a)
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc m (MVar m a)
forall (m :: * -> *) a. MonadConc m => m (MVar m a)
newEmptyMVar
newEmptyMVarN :: String -> IsConc m (MVar (IsConc m) a)
newEmptyMVarN = m (MVar m a) -> IsConc m (MVar m a)
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m (MVar m a) -> IsConc m (MVar m a))
-> (String -> m (MVar m a)) -> String -> IsConc m (MVar m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> m (MVar m a)
forall (m :: * -> *) a. MonadConc m => String -> m (MVar m a)
newEmptyMVarN
readMVar :: MVar (IsConc m) a -> IsConc m a
readMVar = m a -> IsConc m a
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m a -> IsConc m a) -> (MVar m a -> m a) -> MVar m a -> IsConc m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MVar m a -> m a
forall (m :: * -> *) a. MonadConc m => MVar m a -> m a
readMVar
tryReadMVar :: MVar (IsConc m) a -> IsConc m (Maybe a)
tryReadMVar = m (Maybe a) -> IsConc m (Maybe a)
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m (Maybe a) -> IsConc m (Maybe a))
-> (MVar m a -> m (Maybe a)) -> MVar m a -> IsConc m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MVar m a -> m (Maybe a)
forall (m :: * -> *) a. MonadConc m => MVar m a -> m (Maybe a)
tryReadMVar
putMVar :: MVar (IsConc m) a -> a -> IsConc m ()
putMVar MVar (IsConc m) a
v = m () -> IsConc m ()
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m () -> IsConc m ()) -> (a -> m ()) -> a -> IsConc m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MVar m a -> a -> m ()
forall (m :: * -> *) a. MonadConc m => MVar m a -> a -> m ()
putMVar MVar m a
MVar (IsConc m) a
v
tryPutMVar :: MVar (IsConc m) a -> a -> IsConc m Bool
tryPutMVar MVar (IsConc m) a
v = m Bool -> IsConc m Bool
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m Bool -> IsConc m Bool) -> (a -> m Bool) -> a -> IsConc m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MVar m a -> a -> m Bool
forall (m :: * -> *) a. MonadConc m => MVar m a -> a -> m Bool
tryPutMVar MVar m a
MVar (IsConc m) a
v
takeMVar :: MVar (IsConc m) a -> IsConc m a
takeMVar = m a -> IsConc m a
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m a -> IsConc m a) -> (MVar m a -> m a) -> MVar m a -> IsConc m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MVar m a -> m a
forall (m :: * -> *) a. MonadConc m => MVar m a -> m a
takeMVar
tryTakeMVar :: MVar (IsConc m) a -> IsConc m (Maybe a)
tryTakeMVar = m (Maybe a) -> IsConc m (Maybe a)
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m (Maybe a) -> IsConc m (Maybe a))
-> (MVar m a -> m (Maybe a)) -> MVar m a -> IsConc m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MVar m a -> m (Maybe a)
forall (m :: * -> *) a. MonadConc m => MVar m a -> m (Maybe a)
tryTakeMVar
newIORef :: a -> IsConc m (IORef (IsConc m) a)
newIORef = m (IORef m a) -> IsConc m (IORef m a)
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m (IORef m a) -> IsConc m (IORef m a))
-> (a -> m (IORef m a)) -> a -> IsConc m (IORef m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> m (IORef m a)
forall (m :: * -> *) a. MonadConc m => a -> m (IORef m a)
newIORef
newIORefN :: String -> a -> IsConc m (IORef (IsConc m) a)
newIORefN String
n = m (IORef m a) -> IsConc m (IORef m a)
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m (IORef m a) -> IsConc m (IORef m a))
-> (a -> m (IORef m a)) -> a -> IsConc m (IORef m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> a -> m (IORef m a)
forall (m :: * -> *) a. MonadConc m => String -> a -> m (IORef m a)
newIORefN String
n
readIORef :: IORef (IsConc m) a -> IsConc m a
readIORef = m a -> IsConc m a
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m a -> IsConc m a)
-> (IORef m a -> m a) -> IORef m a -> IsConc m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IORef m a -> m a
forall (m :: * -> *) a. MonadConc m => IORef m a -> m a
readIORef
atomicModifyIORef :: IORef (IsConc m) a -> (a -> (a, b)) -> IsConc m b
atomicModifyIORef IORef (IsConc m) a
r = m b -> IsConc m b
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m b -> IsConc m b)
-> ((a -> (a, b)) -> m b) -> (a -> (a, b)) -> IsConc m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IORef m a -> (a -> (a, b)) -> m b
forall (m :: * -> *) a b.
MonadConc m =>
IORef m a -> (a -> (a, b)) -> m b
atomicModifyIORef IORef m a
IORef (IsConc m) a
r
writeIORef :: IORef (IsConc m) a -> a -> IsConc m ()
writeIORef IORef (IsConc m) a
r = m () -> IsConc m ()
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m () -> IsConc m ()) -> (a -> m ()) -> a -> IsConc m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IORef m a -> a -> m ()
forall (m :: * -> *) a. MonadConc m => IORef m a -> a -> m ()
writeIORef IORef m a
IORef (IsConc m) a
r
atomicWriteIORef :: IORef (IsConc m) a -> a -> IsConc m ()
atomicWriteIORef IORef (IsConc m) a
r = m () -> IsConc m ()
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m () -> IsConc m ()) -> (a -> m ()) -> a -> IsConc m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IORef m a -> a -> m ()
forall (m :: * -> *) a. MonadConc m => IORef m a -> a -> m ()
atomicWriteIORef IORef m a
IORef (IsConc m) a
r
readForCAS :: IORef (IsConc m) a -> IsConc m (Ticket (IsConc m) a)
readForCAS = m (Ticket m a) -> IsConc m (Ticket m a)
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m (Ticket m a) -> IsConc m (Ticket m a))
-> (IORef m a -> m (Ticket m a))
-> IORef m a
-> IsConc m (Ticket m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IORef m a -> m (Ticket m a)
forall (m :: * -> *) a. MonadConc m => IORef m a -> m (Ticket m a)
readForCAS
peekTicket' :: Proxy (IsConc m) -> Ticket (IsConc m) a -> a
peekTicket' Proxy (IsConc m)
_ = Proxy m -> Ticket m a -> a
forall (m :: * -> *) a. MonadConc m => Proxy m -> Ticket m a -> a
peekTicket' (Proxy m
forall k (t :: k). Proxy t
Proxy :: Proxy m)
casIORef :: IORef (IsConc m) a
-> Ticket (IsConc m) a -> a -> IsConc m (Bool, Ticket (IsConc m) a)
casIORef IORef (IsConc m) a
r Ticket (IsConc m) a
t = m (Bool, Ticket m a) -> IsConc m (Bool, Ticket m a)
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m (Bool, Ticket m a) -> IsConc m (Bool, Ticket m a))
-> (a -> m (Bool, Ticket m a)) -> a -> IsConc m (Bool, Ticket m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IORef m a -> Ticket m a -> a -> m (Bool, Ticket m a)
forall (m :: * -> *) a.
MonadConc m =>
IORef m a -> Ticket m a -> a -> m (Bool, Ticket m a)
casIORef IORef m a
IORef (IsConc m) a
r Ticket m a
Ticket (IsConc m) a
t
modifyIORefCAS :: IORef (IsConc m) a -> (a -> (a, b)) -> IsConc m b
modifyIORefCAS IORef (IsConc m) a
r = m b -> IsConc m b
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m b -> IsConc m b)
-> ((a -> (a, b)) -> m b) -> (a -> (a, b)) -> IsConc m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IORef m a -> (a -> (a, b)) -> m b
forall (m :: * -> *) a b.
MonadConc m =>
IORef m a -> (a -> (a, b)) -> m b
modifyIORefCAS IORef m a
IORef (IsConc m) a
r
modifyIORefCAS_ :: IORef (IsConc m) a -> (a -> a) -> IsConc m ()
modifyIORefCAS_ IORef (IsConc m) a
r = m () -> IsConc m ()
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m () -> IsConc m ())
-> ((a -> a) -> m ()) -> (a -> a) -> IsConc m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IORef m a -> (a -> a) -> m ()
forall (m :: * -> *) a.
MonadConc m =>
IORef m a -> (a -> a) -> m ()
modifyIORefCAS_ IORef m a
IORef (IsConc m) a
r
atomically :: STM (IsConc m) a -> IsConc m a
atomically = m a -> IsConc m a
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m a -> IsConc m a)
-> (IsSTM (STM m) a -> m a) -> IsSTM (STM m) a -> IsConc m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m a -> m a
forall (m :: * -> *) a. MonadConc m => STM m a -> m a
atomically (STM m a -> m a)
-> (IsSTM (STM m) a -> STM m a) -> IsSTM (STM m) a -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IsSTM (STM m) a -> STM m a
forall (m :: * -> *) a. MonadSTM m => IsSTM m a -> m a
fromIsSTM
newTVarConc :: a -> IsConc m (TVar (STM (IsConc m)) a)
newTVarConc = m (TVar (STM m) a) -> IsConc m (TVar (STM m) a)
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m (TVar (STM m) a) -> IsConc m (TVar (STM m) a))
-> (a -> m (TVar (STM m) a)) -> a -> IsConc m (TVar (STM m) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> m (TVar (STM m) a)
forall (m :: * -> *) a. MonadConc m => a -> m (TVar (STM m) a)
newTVarConc
readTVarConc :: TVar (STM (IsConc m)) a -> IsConc m a
readTVarConc = m a -> IsConc m a
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc (m a -> IsConc m a)
-> (TVar (STM m) a -> m a) -> TVar (STM m) a -> IsConc m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TVar (STM m) a -> m a
forall (m :: * -> *) a. MonadConc m => TVar (STM m) a -> m a
readTVarConc
getMaskingState :: IsConc m MaskingState
getMaskingState = m MaskingState -> IsConc m MaskingState
forall (m :: * -> *) a. MonadConc m => m a -> IsConc m a
toIsConc m MaskingState
forall (m :: * -> *). MonadConc m => m MaskingState
getMaskingState
#define INSTANCE(T,C,F) \
instance C => MonadConc (T m) where { \
type STM (T m) = STM m ; \
type MVar (T m) = MVar m ; \
type IORef (T m) = IORef m ; \
type Ticket (T m) = Ticket m ; \
type ThreadId (T m) = ThreadId m ; \
\
forkWithUnmask = liftedFork F forkWithUnmask ; \
forkWithUnmaskN n = liftedFork F (forkWithUnmaskN n ) ; \
forkOnWithUnmask i = liftedFork F (forkOnWithUnmask i) ; \
forkOnWithUnmaskN n i = liftedFork F (forkOnWithUnmaskN n i) ; \
forkOSWithUnmask = liftedFork F forkOSWithUnmask ; \
forkOSWithUnmaskN n = liftedFork F (forkOSWithUnmaskN n ) ; \
\
supportsBoundThreads = lift supportsBoundThreads ; \
isCurrentThreadBound = lift isCurrentThreadBound ; \
\
getNumCapabilities = lift getNumCapabilities ; \
setNumCapabilities = lift . setNumCapabilities ; \
myThreadId = lift myThreadId ; \
yield = lift yield ; \
threadDelay = lift . threadDelay ; \
throwTo t = lift . throwTo t ; \
newEmptyMVar = lift newEmptyMVar ; \
newEmptyMVarN = lift . newEmptyMVarN ; \
readMVar = lift . readMVar ; \
tryReadMVar = lift . tryReadMVar ; \
putMVar v = lift . putMVar v ; \
tryPutMVar v = lift . tryPutMVar v ; \
takeMVar = lift . takeMVar ; \
tryTakeMVar = lift . tryTakeMVar ; \
newIORef = lift . newIORef ; \
newIORefN n = lift . newIORefN n ; \
readIORef = lift . readIORef ; \
atomicModifyIORef r = lift . atomicModifyIORef r ; \
writeIORef r = lift . writeIORef r ; \
atomicWriteIORef r = lift . atomicWriteIORef r ; \
readForCAS = lift . readForCAS ; \
peekTicket' _ = peekTicket' (Proxy :: Proxy m) ; \
casIORef r t = lift . casIORef r t ; \
modifyIORefCAS r = lift . modifyIORefCAS r ; \
modifyIORefCAS_ r = lift . modifyIORefCAS_ r ; \
atomically = lift . atomically ; \
newTVarConc = lift . newTVarConc ; \
readTVarConc = lift . readTVarConc ; \
getMaskingState = lift getMaskingState ; \
unsafeUnmask = liftedF F unsafeUnmask }
INSTANCE(ReaderT r, MonadConc m, id)
INSTANCE(IdentityT, MonadConc m, id)
INSTANCE(WL.WriterT w, (MonadConc m, Monoid w), fst)
INSTANCE(WS.WriterT w, (MonadConc m, Monoid w), fst)
INSTANCE(SL.StateT s, MonadConc m, fst)
INSTANCE(SS.StateT s, MonadConc m, fst)
INSTANCE(RL.RWST r w s, (MonadConc m, Monoid w), (\(a,_,_) -> a))
INSTANCE(RS.RWST r w s, (MonadConc m, Monoid w), (\(a,_,_) -> a))
#undef INSTANCE
liftedF :: (MonadTransControl t, MonadConc m)
=> (forall x. StT t x -> x)
-> (m a -> m b)
-> t m a
-> t m b
liftedF :: (forall x. StT t x -> x) -> (m a -> m b) -> t m a -> t m b
liftedF forall x. StT t x -> x
unst m a -> m b
f t m a
ma = (Run t -> m b) -> t m b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTransControl t, Monad m) =>
(Run t -> m a) -> t m a
liftWith ((Run t -> m b) -> t m b) -> (Run t -> m b) -> t m b
forall a b. (a -> b) -> a -> b
$ \Run t
run -> m a -> m b
f (StT t a -> a
forall x. StT t x -> x
unst (StT t a -> a) -> m (StT t a) -> m a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> t m a -> m (StT t a)
Run t
run t m a
ma)
liftedFork :: (MonadTransControl t, MonadConc m)
=> (forall x. StT t x -> x)
-> (((forall x. m x -> m x) -> m a) -> m b)
-> ((forall x. t m x -> t m x) -> t m a)
-> t m b
liftedFork :: (forall x. StT t x -> x)
-> (((forall x. m x -> m x) -> m a) -> m b)
-> ((forall x. t m x -> t m x) -> t m a)
-> t m b
liftedFork forall x. StT t x -> x
unst ((forall x. m x -> m x) -> m a) -> m b
f (forall x. t m x -> t m x) -> t m a
ma = (Run t -> m b) -> t m b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTransControl t, Monad m) =>
(Run t -> m a) -> t m a
liftWith ((Run t -> m b) -> t m b) -> (Run t -> m b) -> t m b
forall a b. (a -> b) -> a -> b
$ \Run t
run ->
((forall x. m x -> m x) -> m a) -> m b
f (\forall x. m x -> m x
unmask -> StT t a -> a
forall x. StT t x -> x
unst (StT t a -> a) -> m (StT t a) -> m a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> t m a -> m (StT t a)
Run t
run ((forall x. t m x -> t m x) -> t m a
ma ((forall x. t m x -> t m x) -> t m a)
-> (forall x. t m x -> t m x) -> t m a
forall a b. (a -> b) -> a -> b
$ (forall x. StT t x -> x) -> (m x -> m x) -> t m x -> t m x
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a b.
(MonadTransControl t, MonadConc m) =>
(forall x. StT t x -> x) -> (m a -> m b) -> t m a -> t m b
liftedF forall x. StT t x -> x
unst m x -> m x
forall x. m x -> m x
unmask))