{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
module Test.DejaFu.Types where
import qualified Control.Concurrent as IO
import Control.DeepSeq (NFData(..))
import Control.Exception (Exception(..),
MaskingState(..),
SomeException)
import Control.Monad (forever)
import Control.Monad.Catch (MonadThrow)
import Control.Monad.Catch.Pure (CatchT)
import qualified Control.Monad.ST as ST
import Control.Monad.Trans.Class (lift)
import Data.Function (on)
import Data.Functor.Contravariant (Contravariant(..))
import Data.Functor.Contravariant.Divisible (Divisible(..))
import qualified Data.IORef as IO
import Data.Kind (Type)
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as M
import Data.Semigroup (Semigroup(..))
import Data.Set (Set)
import qualified Data.Set as S
import qualified Data.STRef as ST
import GHC.Generics (Generic, V1)
class MonadThrow m => MonadDejaFu m where
type Ref m :: Type -> Type
newRef :: a -> m (Ref m a)
readRef :: Ref m a -> m a
writeRef :: Ref m a -> a -> m ()
type BoundThread m :: Type -> Type
forkBoundThread :: Maybe (m (BoundThread m a))
runInBoundThread :: BoundThread m a -> m a -> m a
killBoundThread :: BoundThread m a -> m ()
data IOBoundThread a = IOBoundThread
{ forall a. IOBoundThread a -> IO a -> IO a
iobtRunInBoundThread :: IO a -> IO a
, forall a. IOBoundThread a -> IO ()
iobtKillBoundThread :: IO ()
}
instance MonadDejaFu IO where
type Ref IO = IO.IORef
newRef :: forall a. a -> IO (Ref IO a)
newRef = forall a. a -> IO (IORef a)
IO.newIORef
readRef :: forall a. Ref IO a -> IO a
readRef = forall a. IORef a -> IO a
IO.readIORef
writeRef :: forall a. Ref IO a -> a -> IO ()
writeRef = forall a. IORef a -> a -> IO ()
IO.writeIORef
type BoundThread IO = IOBoundThread
forkBoundThread :: forall a. Maybe (IO (BoundThread IO a))
forkBoundThread = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ do
MVar (IO a)
runboundIO <- forall a. IO (MVar a)
IO.newEmptyMVar
MVar a
getboundIO <- forall a. IO (MVar a)
IO.newEmptyMVar
ThreadId
tid <- IO () -> IO ThreadId
IO.forkOS (forall {a} {b}. MVar (IO a) -> MVar a -> IO b
go MVar (IO a)
runboundIO MVar a
getboundIO)
forall (f :: * -> *) a. Applicative f => a -> f a
pure IOBoundThread
{ iobtRunInBoundThread :: IO a -> IO a
iobtRunInBoundThread = forall {a} {b}. MVar a -> MVar b -> a -> IO b
run MVar (IO a)
runboundIO MVar a
getboundIO
, iobtKillBoundThread :: IO ()
iobtKillBoundThread = ThreadId -> IO ()
IO.killThread ThreadId
tid
}
where
go :: MVar (IO a) -> MVar a -> IO b
go MVar (IO a)
runboundIO MVar a
getboundIO = forall (f :: * -> *) a b. Applicative f => f a -> f b
forever forall a b. (a -> b) -> a -> b
$ do
IO a
na <- forall a. MVar a -> IO a
IO.takeMVar MVar (IO a)
runboundIO
forall a. MVar a -> a -> IO ()
IO.putMVar MVar a
getboundIO forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO a
na
run :: MVar a -> MVar b -> a -> IO b
run MVar a
runboundIO MVar b
getboundIO a
ma = do
forall a. MVar a -> a -> IO ()
IO.putMVar MVar a
runboundIO a
ma
forall a. MVar a -> IO a
IO.takeMVar MVar b
getboundIO
runInBoundThread :: forall a. BoundThread IO a -> IO a -> IO a
runInBoundThread = forall a. IOBoundThread a -> IO a -> IO a
iobtRunInBoundThread
killBoundThread :: forall a. BoundThread IO a -> IO ()
killBoundThread = forall a. IOBoundThread a -> IO ()
iobtKillBoundThread
instance MonadDejaFu (CatchT (ST.ST t)) where
type Ref (CatchT (ST.ST t)) = ST.STRef t
newRef :: forall a. a -> CatchT (ST t) (Ref (CatchT (ST t)) a)
newRef = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a s. a -> ST s (STRef s a)
ST.newSTRef
readRef :: forall a. Ref (CatchT (ST t)) a -> CatchT (ST t) a
readRef = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. STRef s a -> ST s a
ST.readSTRef
writeRef :: forall a. Ref (CatchT (ST t)) a -> a -> CatchT (ST t) ()
writeRef Ref (CatchT (ST t)) a
r = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. STRef s a -> a -> ST s ()
ST.writeSTRef Ref (CatchT (ST t)) a
r
type BoundThread (CatchT (ST.ST t)) = V1
forkBoundThread :: forall a. Maybe (CatchT (ST t) (BoundThread (CatchT (ST t)) a))
forkBoundThread = forall a. Maybe a
Nothing
runInBoundThread :: forall a.
BoundThread (CatchT (ST t)) a -> CatchT (ST t) a -> CatchT (ST t) a
runInBoundThread = forall a. HasCallStack => a
undefined
killBoundThread :: forall a. BoundThread (CatchT (ST t)) a -> CatchT (ST t) ()
killBoundThread = forall a. HasCallStack => a
undefined
newtype ThreadId = ThreadId Id
deriving (ThreadId -> ThreadId -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ThreadId -> ThreadId -> Bool
$c/= :: ThreadId -> ThreadId -> Bool
== :: ThreadId -> ThreadId -> Bool
$c== :: ThreadId -> ThreadId -> Bool
Eq, Eq ThreadId
ThreadId -> ThreadId -> Bool
ThreadId -> ThreadId -> Ordering
ThreadId -> ThreadId -> ThreadId
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ThreadId -> ThreadId -> ThreadId
$cmin :: ThreadId -> ThreadId -> ThreadId
max :: ThreadId -> ThreadId -> ThreadId
$cmax :: ThreadId -> ThreadId -> ThreadId
>= :: ThreadId -> ThreadId -> Bool
$c>= :: ThreadId -> ThreadId -> Bool
> :: ThreadId -> ThreadId -> Bool
$c> :: ThreadId -> ThreadId -> Bool
<= :: ThreadId -> ThreadId -> Bool
$c<= :: ThreadId -> ThreadId -> Bool
< :: ThreadId -> ThreadId -> Bool
$c< :: ThreadId -> ThreadId -> Bool
compare :: ThreadId -> ThreadId -> Ordering
$ccompare :: ThreadId -> ThreadId -> Ordering
Ord, ThreadId -> ()
forall a. (a -> ()) -> NFData a
rnf :: ThreadId -> ()
$crnf :: ThreadId -> ()
NFData)
instance Show ThreadId where
show :: ThreadId -> String
show (ThreadId Id
id_) = forall a. Show a => a -> String
show Id
id_
deriving instance Generic ThreadId
newtype IORefId = IORefId Id
deriving (IORefId -> IORefId -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IORefId -> IORefId -> Bool
$c/= :: IORefId -> IORefId -> Bool
== :: IORefId -> IORefId -> Bool
$c== :: IORefId -> IORefId -> Bool
Eq, Eq IORefId
IORefId -> IORefId -> Bool
IORefId -> IORefId -> Ordering
IORefId -> IORefId -> IORefId
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: IORefId -> IORefId -> IORefId
$cmin :: IORefId -> IORefId -> IORefId
max :: IORefId -> IORefId -> IORefId
$cmax :: IORefId -> IORefId -> IORefId
>= :: IORefId -> IORefId -> Bool
$c>= :: IORefId -> IORefId -> Bool
> :: IORefId -> IORefId -> Bool
$c> :: IORefId -> IORefId -> Bool
<= :: IORefId -> IORefId -> Bool
$c<= :: IORefId -> IORefId -> Bool
< :: IORefId -> IORefId -> Bool
$c< :: IORefId -> IORefId -> Bool
compare :: IORefId -> IORefId -> Ordering
$ccompare :: IORefId -> IORefId -> Ordering
Ord, IORefId -> ()
forall a. (a -> ()) -> NFData a
rnf :: IORefId -> ()
$crnf :: IORefId -> ()
NFData, forall x. Rep IORefId x -> IORefId
forall x. IORefId -> Rep IORefId x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IORefId x -> IORefId
$cfrom :: forall x. IORefId -> Rep IORefId x
Generic)
instance Show IORefId where
show :: IORefId -> String
show (IORefId Id
id_) = forall a. Show a => a -> String
show Id
id_
newtype MVarId = MVarId Id
deriving (MVarId -> MVarId -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MVarId -> MVarId -> Bool
$c/= :: MVarId -> MVarId -> Bool
== :: MVarId -> MVarId -> Bool
$c== :: MVarId -> MVarId -> Bool
Eq, Eq MVarId
MVarId -> MVarId -> Bool
MVarId -> MVarId -> Ordering
MVarId -> MVarId -> MVarId
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: MVarId -> MVarId -> MVarId
$cmin :: MVarId -> MVarId -> MVarId
max :: MVarId -> MVarId -> MVarId
$cmax :: MVarId -> MVarId -> MVarId
>= :: MVarId -> MVarId -> Bool
$c>= :: MVarId -> MVarId -> Bool
> :: MVarId -> MVarId -> Bool
$c> :: MVarId -> MVarId -> Bool
<= :: MVarId -> MVarId -> Bool
$c<= :: MVarId -> MVarId -> Bool
< :: MVarId -> MVarId -> Bool
$c< :: MVarId -> MVarId -> Bool
compare :: MVarId -> MVarId -> Ordering
$ccompare :: MVarId -> MVarId -> Ordering
Ord, MVarId -> ()
forall a. (a -> ()) -> NFData a
rnf :: MVarId -> ()
$crnf :: MVarId -> ()
NFData)
instance Show MVarId where
show :: MVarId -> String
show (MVarId Id
id_) = forall a. Show a => a -> String
show Id
id_
deriving instance Generic MVarId
newtype TVarId = TVarId Id
deriving (TVarId -> TVarId -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TVarId -> TVarId -> Bool
$c/= :: TVarId -> TVarId -> Bool
== :: TVarId -> TVarId -> Bool
$c== :: TVarId -> TVarId -> Bool
Eq, Eq TVarId
TVarId -> TVarId -> Bool
TVarId -> TVarId -> Ordering
TVarId -> TVarId -> TVarId
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: TVarId -> TVarId -> TVarId
$cmin :: TVarId -> TVarId -> TVarId
max :: TVarId -> TVarId -> TVarId
$cmax :: TVarId -> TVarId -> TVarId
>= :: TVarId -> TVarId -> Bool
$c>= :: TVarId -> TVarId -> Bool
> :: TVarId -> TVarId -> Bool
$c> :: TVarId -> TVarId -> Bool
<= :: TVarId -> TVarId -> Bool
$c<= :: TVarId -> TVarId -> Bool
< :: TVarId -> TVarId -> Bool
$c< :: TVarId -> TVarId -> Bool
compare :: TVarId -> TVarId -> Ordering
$ccompare :: TVarId -> TVarId -> Ordering
Ord, TVarId -> ()
forall a. (a -> ()) -> NFData a
rnf :: TVarId -> ()
$crnf :: TVarId -> ()
NFData)
instance Show TVarId where
show :: TVarId -> String
show (TVarId Id
id_) = forall a. Show a => a -> String
show Id
id_
deriving instance Generic TVarId
data Id = Id (Maybe String) {-# UNPACK #-} !Int
instance Eq Id where
(Id Maybe String
_ Int
i) == :: Id -> Id -> Bool
== (Id Maybe String
_ Int
j) = Int
i forall a. Eq a => a -> a -> Bool
== Int
j
instance Ord Id where
compare :: Id -> Id -> Ordering
compare (Id Maybe String
_ Int
i) (Id Maybe String
_ Int
j) = forall a. Ord a => a -> a -> Ordering
compare Int
i Int
j
instance Show Id where
show :: Id -> String
show (Id (Just String
n) Int
_) = String
n
show (Id Maybe String
_ Int
i) = forall a. Show a => a -> String
show Int
i
deriving instance Generic Id
instance NFData Id
initialThread :: ThreadId
initialThread :: ThreadId
initialThread = Id -> ThreadId
ThreadId (Maybe String -> Int -> Id
Id (forall a. a -> Maybe a
Just String
"main") Int
0)
data ThreadAction =
Fork ThreadId
| ForkOS ThreadId
| SupportsBoundThreads Bool
| IsCurrentThreadBound Bool
| MyThreadId
| GetNumCapabilities Int
| SetNumCapabilities Int
| Yield
| ThreadDelay Int
| NewMVar MVarId
| PutMVar MVarId [ThreadId]
| BlockedPutMVar MVarId
| TryPutMVar MVarId Bool [ThreadId]
| ReadMVar MVarId
| TryReadMVar MVarId Bool
| BlockedReadMVar MVarId
| TakeMVar MVarId [ThreadId]
| BlockedTakeMVar MVarId
| TryTakeMVar MVarId Bool [ThreadId]
| NewIORef IORefId
| ReadIORef IORefId
| ReadIORefCas IORefId
| ModIORef IORefId
| ModIORefCas IORefId
| WriteIORef IORefId
| CasIORef IORefId Bool
| CommitIORef ThreadId IORefId
| STM [TAction] [ThreadId]
| ThrownSTM [TAction] (Maybe MaskingState)
| BlockedSTM [TAction]
| Catching
| PopCatching
| Throw (Maybe MaskingState)
| ThrowTo ThreadId (Maybe MaskingState)
| BlockedThrowTo ThreadId
| SetMasking Bool MaskingState
| ResetMasking Bool MaskingState
| GetMaskingState MaskingState
| LiftIO
| Return
| Stop
| RegisterInvariant
deriving (ThreadAction -> ThreadAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ThreadAction -> ThreadAction -> Bool
$c/= :: ThreadAction -> ThreadAction -> Bool
== :: ThreadAction -> ThreadAction -> Bool
$c== :: ThreadAction -> ThreadAction -> Bool
Eq, forall x. Rep ThreadAction x -> ThreadAction
forall x. ThreadAction -> Rep ThreadAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ThreadAction x -> ThreadAction
$cfrom :: forall x. ThreadAction -> Rep ThreadAction x
Generic, Int -> ThreadAction -> ShowS
[ThreadAction] -> ShowS
ThreadAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ThreadAction] -> ShowS
$cshowList :: [ThreadAction] -> ShowS
show :: ThreadAction -> String
$cshow :: ThreadAction -> String
showsPrec :: Int -> ThreadAction -> ShowS
$cshowsPrec :: Int -> ThreadAction -> ShowS
Show)
instance NFData ThreadAction where
rnf :: ThreadAction -> ()
rnf (Fork ThreadId
t) = forall a. NFData a => a -> ()
rnf ThreadId
t
rnf (ForkOS ThreadId
t) = forall a. NFData a => a -> ()
rnf ThreadId
t
rnf (SupportsBoundThreads Bool
b) = forall a. NFData a => a -> ()
rnf Bool
b
rnf (IsCurrentThreadBound Bool
b) = forall a. NFData a => a -> ()
rnf Bool
b
rnf ThreadAction
MyThreadId = ()
rnf (GetNumCapabilities Int
i) = forall a. NFData a => a -> ()
rnf Int
i
rnf (SetNumCapabilities Int
i) = forall a. NFData a => a -> ()
rnf Int
i
rnf ThreadAction
Yield = ()
rnf (ThreadDelay Int
i) = forall a. NFData a => a -> ()
rnf Int
i
rnf (NewMVar MVarId
m) = forall a. NFData a => a -> ()
rnf MVarId
m
rnf (PutMVar MVarId
m [ThreadId]
ts) = forall a. NFData a => a -> ()
rnf (MVarId
m, [ThreadId]
ts)
rnf (BlockedPutMVar MVarId
m) = forall a. NFData a => a -> ()
rnf MVarId
m
rnf (TryPutMVar MVarId
m Bool
b [ThreadId]
ts) = forall a. NFData a => a -> ()
rnf (MVarId
m, Bool
b, [ThreadId]
ts)
rnf (ReadMVar MVarId
m) = forall a. NFData a => a -> ()
rnf MVarId
m
rnf (TryReadMVar MVarId
m Bool
b) = forall a. NFData a => a -> ()
rnf (MVarId
m, Bool
b)
rnf (BlockedReadMVar MVarId
m) = forall a. NFData a => a -> ()
rnf MVarId
m
rnf (TakeMVar MVarId
m [ThreadId]
ts) = forall a. NFData a => a -> ()
rnf (MVarId
m, [ThreadId]
ts)
rnf (BlockedTakeMVar MVarId
m) = forall a. NFData a => a -> ()
rnf MVarId
m
rnf (TryTakeMVar MVarId
m Bool
b [ThreadId]
ts) = forall a. NFData a => a -> ()
rnf (MVarId
m, Bool
b, [ThreadId]
ts)
rnf (NewIORef IORefId
c) = forall a. NFData a => a -> ()
rnf IORefId
c
rnf (ReadIORef IORefId
c) = forall a. NFData a => a -> ()
rnf IORefId
c
rnf (ReadIORefCas IORefId
c) = forall a. NFData a => a -> ()
rnf IORefId
c
rnf (ModIORef IORefId
c) = forall a. NFData a => a -> ()
rnf IORefId
c
rnf (ModIORefCas IORefId
c) = forall a. NFData a => a -> ()
rnf IORefId
c
rnf (WriteIORef IORefId
c) = forall a. NFData a => a -> ()
rnf IORefId
c
rnf (CasIORef IORefId
c Bool
b) = forall a. NFData a => a -> ()
rnf (IORefId
c, Bool
b)
rnf (CommitIORef ThreadId
t IORefId
c) = forall a. NFData a => a -> ()
rnf (ThreadId
t, IORefId
c)
rnf (STM [TAction]
as [ThreadId]
ts) = forall a. NFData a => a -> ()
rnf ([TAction]
as, [ThreadId]
ts)
rnf (ThrownSTM [TAction]
as (Just MaskingState
m)) = MaskingState
m seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf [TAction]
as
rnf (ThrownSTM [TAction]
as Maybe MaskingState
Nothing) = forall a. NFData a => a -> ()
rnf [TAction]
as
rnf (BlockedSTM [TAction]
as) = forall a. NFData a => a -> ()
rnf [TAction]
as
rnf ThreadAction
Catching = ()
rnf ThreadAction
PopCatching = ()
rnf (Throw (Just MaskingState
m)) = MaskingState
m seq :: forall a b. a -> b -> b
`seq` ()
rnf (Throw Maybe MaskingState
Nothing) = ()
rnf (ThrowTo ThreadId
t (Just MaskingState
m)) = MaskingState
m seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf ThreadId
t
rnf (ThrowTo ThreadId
t Maybe MaskingState
Nothing) = forall a. NFData a => a -> ()
rnf ThreadId
t
rnf (BlockedThrowTo ThreadId
t) = forall a. NFData a => a -> ()
rnf ThreadId
t
rnf (SetMasking Bool
b MaskingState
m) = forall a. NFData a => a -> ()
rnf (Bool
b, forall a. Show a => a -> String
show MaskingState
m)
rnf (ResetMasking Bool
b MaskingState
m) = forall a. NFData a => a -> ()
rnf (Bool
b, forall a. Show a => a -> String
show MaskingState
m)
rnf (GetMaskingState MaskingState
m) = MaskingState
m seq :: forall a b. a -> b -> b
`seq` ()
rnf ThreadAction
LiftIO = ()
rnf ThreadAction
Return = ()
rnf ThreadAction
Stop = ()
rnf ThreadAction
RegisterInvariant = ()
data Lookahead =
WillFork
| WillForkOS
| WillSupportsBoundThreads
| WillIsCurrentThreadBound
| WillMyThreadId
| WillGetNumCapabilities
| WillSetNumCapabilities Int
| WillYield
| WillThreadDelay Int
| WillNewMVar
| WillPutMVar MVarId
| WillTryPutMVar MVarId
| WillReadMVar MVarId
| WillTryReadMVar MVarId
| WillTakeMVar MVarId
| WillTryTakeMVar MVarId
| WillNewIORef
| WillReadIORef IORefId
| WillReadIORefCas IORefId
| WillModIORef IORefId
| WillModIORefCas IORefId
| WillWriteIORef IORefId
| WillCasIORef IORefId
| WillCommitIORef ThreadId IORefId
| WillSTM
| WillCatching
| WillPopCatching
| WillThrow
| WillThrowTo ThreadId
| WillSetMasking Bool MaskingState
| WillResetMasking Bool MaskingState
| WillGetMaskingState
| WillLiftIO
| WillReturn
| WillStop
| WillRegisterInvariant
deriving (Lookahead -> Lookahead -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Lookahead -> Lookahead -> Bool
$c/= :: Lookahead -> Lookahead -> Bool
== :: Lookahead -> Lookahead -> Bool
$c== :: Lookahead -> Lookahead -> Bool
Eq, forall x. Rep Lookahead x -> Lookahead
forall x. Lookahead -> Rep Lookahead x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Lookahead x -> Lookahead
$cfrom :: forall x. Lookahead -> Rep Lookahead x
Generic, Int -> Lookahead -> ShowS
[Lookahead] -> ShowS
Lookahead -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Lookahead] -> ShowS
$cshowList :: [Lookahead] -> ShowS
show :: Lookahead -> String
$cshow :: Lookahead -> String
showsPrec :: Int -> Lookahead -> ShowS
$cshowsPrec :: Int -> Lookahead -> ShowS
Show)
instance NFData Lookahead where
rnf :: Lookahead -> ()
rnf Lookahead
WillFork = ()
rnf Lookahead
WillForkOS = ()
rnf Lookahead
WillSupportsBoundThreads = ()
rnf Lookahead
WillIsCurrentThreadBound = ()
rnf Lookahead
WillMyThreadId = ()
rnf Lookahead
WillGetNumCapabilities = ()
rnf (WillSetNumCapabilities Int
i) = forall a. NFData a => a -> ()
rnf Int
i
rnf Lookahead
WillYield = ()
rnf (WillThreadDelay Int
i) = forall a. NFData a => a -> ()
rnf Int
i
rnf Lookahead
WillNewMVar = ()
rnf (WillPutMVar MVarId
m) = forall a. NFData a => a -> ()
rnf MVarId
m
rnf (WillTryPutMVar MVarId
m) = forall a. NFData a => a -> ()
rnf MVarId
m
rnf (WillReadMVar MVarId
m) = forall a. NFData a => a -> ()
rnf MVarId
m
rnf (WillTryReadMVar MVarId
m) = forall a. NFData a => a -> ()
rnf MVarId
m
rnf (WillTakeMVar MVarId
m) = forall a. NFData a => a -> ()
rnf MVarId
m
rnf (WillTryTakeMVar MVarId
m) = forall a. NFData a => a -> ()
rnf MVarId
m
rnf Lookahead
WillNewIORef = ()
rnf (WillReadIORef IORefId
c) = forall a. NFData a => a -> ()
rnf IORefId
c
rnf (WillReadIORefCas IORefId
c) = forall a. NFData a => a -> ()
rnf IORefId
c
rnf (WillModIORef IORefId
c) = forall a. NFData a => a -> ()
rnf IORefId
c
rnf (WillModIORefCas IORefId
c) = forall a. NFData a => a -> ()
rnf IORefId
c
rnf (WillWriteIORef IORefId
c) = forall a. NFData a => a -> ()
rnf IORefId
c
rnf (WillCasIORef IORefId
c) = forall a. NFData a => a -> ()
rnf IORefId
c
rnf (WillCommitIORef ThreadId
t IORefId
c) = forall a. NFData a => a -> ()
rnf (ThreadId
t, IORefId
c)
rnf Lookahead
WillSTM = ()
rnf Lookahead
WillCatching = ()
rnf Lookahead
WillPopCatching = ()
rnf Lookahead
WillThrow = ()
rnf (WillThrowTo ThreadId
t) = forall a. NFData a => a -> ()
rnf ThreadId
t
rnf (WillSetMasking Bool
b MaskingState
m) = forall a. NFData a => a -> ()
rnf (Bool
b, forall a. Show a => a -> String
show MaskingState
m)
rnf (WillResetMasking Bool
b MaskingState
m) = forall a. NFData a => a -> ()
rnf (Bool
b, forall a. Show a => a -> String
show MaskingState
m)
rnf Lookahead
WillGetMaskingState = ()
rnf Lookahead
WillLiftIO = ()
rnf Lookahead
WillReturn = ()
rnf Lookahead
WillStop = ()
rnf Lookahead
WillRegisterInvariant = ()
data TAction =
TNew TVarId
| TRead TVarId
| TWrite TVarId
| TRetry
| TOrElse [TAction] (Maybe [TAction])
| TThrow
| TCatch [TAction] (Maybe [TAction])
| TStop
deriving (TAction -> TAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TAction -> TAction -> Bool
$c/= :: TAction -> TAction -> Bool
== :: TAction -> TAction -> Bool
$c== :: TAction -> TAction -> Bool
Eq, Int -> TAction -> ShowS
[TAction] -> ShowS
TAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TAction] -> ShowS
$cshowList :: [TAction] -> ShowS
show :: TAction -> String
$cshow :: TAction -> String
showsPrec :: Int -> TAction -> ShowS
$cshowsPrec :: Int -> TAction -> ShowS
Show)
deriving instance Generic TAction
instance NFData TAction
type Trace
= [(Decision, [(ThreadId, Lookahead)], ThreadAction)]
data Decision =
Start ThreadId
| Continue
| SwitchTo ThreadId
deriving (Decision -> Decision -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Decision -> Decision -> Bool
$c/= :: Decision -> Decision -> Bool
== :: Decision -> Decision -> Bool
$c== :: Decision -> Decision -> Bool
Eq, Int -> Decision -> ShowS
[Decision] -> ShowS
Decision -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Decision] -> ShowS
$cshowList :: [Decision] -> ShowS
show :: Decision -> String
$cshow :: Decision -> String
showsPrec :: Int -> Decision -> ShowS
$cshowsPrec :: Int -> Decision -> ShowS
Show)
deriving instance Generic Decision
instance NFData Decision
data Condition
= Abort
| Deadlock
| UncaughtException SomeException
| InvariantFailure SomeException
deriving (Int -> Condition -> ShowS
[Condition] -> ShowS
Condition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Condition] -> ShowS
$cshowList :: [Condition] -> ShowS
show :: Condition -> String
$cshow :: Condition -> String
showsPrec :: Int -> Condition -> ShowS
$cshowsPrec :: Int -> Condition -> ShowS
Show, forall x. Rep Condition x -> Condition
forall x. Condition -> Rep Condition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Condition x -> Condition
$cfrom :: forall x. Condition -> Rep Condition x
Generic)
instance Eq Condition where
Condition
Abort == :: Condition -> Condition -> Bool
== Condition
Abort = Bool
True
Condition
Deadlock == Condition
Deadlock = Bool
True
(UncaughtException SomeException
e1) == (UncaughtException SomeException
e2) = forall a. Show a => a -> String
show SomeException
e1 forall a. Eq a => a -> a -> Bool
== forall a. Show a => a -> String
show SomeException
e2
(InvariantFailure SomeException
e1) == (InvariantFailure SomeException
e2) = forall a. Show a => a -> String
show SomeException
e1 forall a. Eq a => a -> a -> Bool
== forall a. Show a => a -> String
show SomeException
e2
Condition
_ == Condition
_ = Bool
False
instance Ord Condition where
compare :: Condition -> Condition -> Ordering
compare = forall a. Ord a => a -> a -> Ordering
compare forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` Condition -> (Int, Maybe String)
transform where
transform :: Condition -> (Int, Maybe String)
transform :: Condition -> (Int, Maybe String)
transform Condition
Abort = (Int
1, forall a. Maybe a
Nothing)
transform Condition
Deadlock = (Int
2, forall a. Maybe a
Nothing)
transform (UncaughtException SomeException
e) = (Int
3, forall a. a -> Maybe a
Just (forall a. Show a => a -> String
show SomeException
e))
transform (InvariantFailure SomeException
e) = (Int
4, forall a. a -> Maybe a
Just (forall a. Show a => a -> String
show SomeException
e))
instance NFData Condition where
rnf :: Condition -> ()
rnf (UncaughtException SomeException
e) = forall a. NFData a => a -> ()
rnf (forall a. Show a => a -> String
show SomeException
e)
rnf (InvariantFailure SomeException
e) = forall a. NFData a => a -> ()
rnf (forall a. Show a => a -> String
show SomeException
e)
rnf Condition
f = Condition
f seq :: forall a b. a -> b -> b
`seq` ()
isAbort :: Condition -> Bool
isAbort :: Condition -> Bool
isAbort Condition
Abort = Bool
True
isAbort Condition
_ = Bool
False
isDeadlock :: Condition -> Bool
isDeadlock :: Condition -> Bool
isDeadlock Condition
Deadlock = Bool
True
isDeadlock Condition
_ = Bool
False
isUncaughtException :: Condition -> Bool
isUncaughtException :: Condition -> Bool
isUncaughtException (UncaughtException SomeException
_) = Bool
True
isUncaughtException Condition
_ = Bool
False
isInvariantFailure :: Condition -> Bool
isInvariantFailure :: Condition -> Bool
isInvariantFailure (InvariantFailure SomeException
_) = Bool
True
isInvariantFailure Condition
_ = Bool
False
data Error
= ScheduledBlockedThread
| ScheduledMissingThread
deriving (Int -> Error -> ShowS
[Error] -> ShowS
Error -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Error] -> ShowS
$cshowList :: [Error] -> ShowS
show :: Error -> String
$cshow :: Error -> String
showsPrec :: Int -> Error -> ShowS
$cshowsPrec :: Int -> Error -> ShowS
Show, Error -> Error -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Error -> Error -> Bool
$c/= :: Error -> Error -> Bool
== :: Error -> Error -> Bool
$c== :: Error -> Error -> Bool
Eq, Eq Error
Error -> Error -> Bool
Error -> Error -> Ordering
Error -> Error -> Error
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Error -> Error -> Error
$cmin :: Error -> Error -> Error
max :: Error -> Error -> Error
$cmax :: Error -> Error -> Error
>= :: Error -> Error -> Bool
$c>= :: Error -> Error -> Bool
> :: Error -> Error -> Bool
$c> :: Error -> Error -> Bool
<= :: Error -> Error -> Bool
$c<= :: Error -> Error -> Bool
< :: Error -> Error -> Bool
$c< :: Error -> Error -> Bool
compare :: Error -> Error -> Ordering
$ccompare :: Error -> Error -> Ordering
Ord, Error
forall a. a -> a -> Bounded a
maxBound :: Error
$cmaxBound :: Error
minBound :: Error
$cminBound :: Error
Bounded, Int -> Error
Error -> Int
Error -> [Error]
Error -> Error
Error -> Error -> [Error]
Error -> Error -> Error -> [Error]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Error -> Error -> Error -> [Error]
$cenumFromThenTo :: Error -> Error -> Error -> [Error]
enumFromTo :: Error -> Error -> [Error]
$cenumFromTo :: Error -> Error -> [Error]
enumFromThen :: Error -> Error -> [Error]
$cenumFromThen :: Error -> Error -> [Error]
enumFrom :: Error -> [Error]
$cenumFrom :: Error -> [Error]
fromEnum :: Error -> Int
$cfromEnum :: Error -> Int
toEnum :: Int -> Error
$ctoEnum :: Int -> Error
pred :: Error -> Error
$cpred :: Error -> Error
succ :: Error -> Error
$csucc :: Error -> Error
Enum, forall x. Rep Error x -> Error
forall x. Error -> Rep Error x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Error x -> Error
$cfrom :: forall x. Error -> Rep Error x
Generic)
instance Exception Error
isSchedulerError :: Error -> Bool
isSchedulerError :: Error -> Bool
isSchedulerError Error
_ = Bool
True
data Bounds = Bounds
{ Bounds -> Maybe PreemptionBound
boundPreemp :: Maybe PreemptionBound
, Bounds -> Maybe FairBound
boundFair :: Maybe FairBound
} deriving (Bounds -> Bounds -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Bounds -> Bounds -> Bool
$c/= :: Bounds -> Bounds -> Bool
== :: Bounds -> Bounds -> Bool
$c== :: Bounds -> Bounds -> Bool
Eq, Eq Bounds
Bounds -> Bounds -> Bool
Bounds -> Bounds -> Ordering
Bounds -> Bounds -> Bounds
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Bounds -> Bounds -> Bounds
$cmin :: Bounds -> Bounds -> Bounds
max :: Bounds -> Bounds -> Bounds
$cmax :: Bounds -> Bounds -> Bounds
>= :: Bounds -> Bounds -> Bool
$c>= :: Bounds -> Bounds -> Bool
> :: Bounds -> Bounds -> Bool
$c> :: Bounds -> Bounds -> Bool
<= :: Bounds -> Bounds -> Bool
$c<= :: Bounds -> Bounds -> Bool
< :: Bounds -> Bounds -> Bool
$c< :: Bounds -> Bounds -> Bool
compare :: Bounds -> Bounds -> Ordering
$ccompare :: Bounds -> Bounds -> Ordering
Ord, ReadPrec [Bounds]
ReadPrec Bounds
Int -> ReadS Bounds
ReadS [Bounds]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Bounds]
$creadListPrec :: ReadPrec [Bounds]
readPrec :: ReadPrec Bounds
$creadPrec :: ReadPrec Bounds
readList :: ReadS [Bounds]
$creadList :: ReadS [Bounds]
readsPrec :: Int -> ReadS Bounds
$creadsPrec :: Int -> ReadS Bounds
Read, Int -> Bounds -> ShowS
[Bounds] -> ShowS
Bounds -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Bounds] -> ShowS
$cshowList :: [Bounds] -> ShowS
show :: Bounds -> String
$cshow :: Bounds -> String
showsPrec :: Int -> Bounds -> ShowS
$cshowsPrec :: Int -> Bounds -> ShowS
Show, forall x. Rep Bounds x -> Bounds
forall x. Bounds -> Rep Bounds x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Bounds x -> Bounds
$cfrom :: forall x. Bounds -> Rep Bounds x
Generic)
instance NFData Bounds
newtype PreemptionBound = PreemptionBound Int
deriving (Int -> PreemptionBound
PreemptionBound -> Int
PreemptionBound -> [PreemptionBound]
PreemptionBound -> PreemptionBound
PreemptionBound -> PreemptionBound -> [PreemptionBound]
PreemptionBound
-> PreemptionBound -> PreemptionBound -> [PreemptionBound]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: PreemptionBound
-> PreemptionBound -> PreemptionBound -> [PreemptionBound]
$cenumFromThenTo :: PreemptionBound
-> PreemptionBound -> PreemptionBound -> [PreemptionBound]
enumFromTo :: PreemptionBound -> PreemptionBound -> [PreemptionBound]
$cenumFromTo :: PreemptionBound -> PreemptionBound -> [PreemptionBound]
enumFromThen :: PreemptionBound -> PreemptionBound -> [PreemptionBound]
$cenumFromThen :: PreemptionBound -> PreemptionBound -> [PreemptionBound]
enumFrom :: PreemptionBound -> [PreemptionBound]
$cenumFrom :: PreemptionBound -> [PreemptionBound]
fromEnum :: PreemptionBound -> Int
$cfromEnum :: PreemptionBound -> Int
toEnum :: Int -> PreemptionBound
$ctoEnum :: Int -> PreemptionBound
pred :: PreemptionBound -> PreemptionBound
$cpred :: PreemptionBound -> PreemptionBound
succ :: PreemptionBound -> PreemptionBound
$csucc :: PreemptionBound -> PreemptionBound
Enum, PreemptionBound -> PreemptionBound -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PreemptionBound -> PreemptionBound -> Bool
$c/= :: PreemptionBound -> PreemptionBound -> Bool
== :: PreemptionBound -> PreemptionBound -> Bool
$c== :: PreemptionBound -> PreemptionBound -> Bool
Eq, Eq PreemptionBound
PreemptionBound -> PreemptionBound -> Bool
PreemptionBound -> PreemptionBound -> Ordering
PreemptionBound -> PreemptionBound -> PreemptionBound
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: PreemptionBound -> PreemptionBound -> PreemptionBound
$cmin :: PreemptionBound -> PreemptionBound -> PreemptionBound
max :: PreemptionBound -> PreemptionBound -> PreemptionBound
$cmax :: PreemptionBound -> PreemptionBound -> PreemptionBound
>= :: PreemptionBound -> PreemptionBound -> Bool
$c>= :: PreemptionBound -> PreemptionBound -> Bool
> :: PreemptionBound -> PreemptionBound -> Bool
$c> :: PreemptionBound -> PreemptionBound -> Bool
<= :: PreemptionBound -> PreemptionBound -> Bool
$c<= :: PreemptionBound -> PreemptionBound -> Bool
< :: PreemptionBound -> PreemptionBound -> Bool
$c< :: PreemptionBound -> PreemptionBound -> Bool
compare :: PreemptionBound -> PreemptionBound -> Ordering
$ccompare :: PreemptionBound -> PreemptionBound -> Ordering
Ord, Integer -> PreemptionBound
PreemptionBound -> PreemptionBound
PreemptionBound -> PreemptionBound -> PreemptionBound
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> PreemptionBound
$cfromInteger :: Integer -> PreemptionBound
signum :: PreemptionBound -> PreemptionBound
$csignum :: PreemptionBound -> PreemptionBound
abs :: PreemptionBound -> PreemptionBound
$cabs :: PreemptionBound -> PreemptionBound
negate :: PreemptionBound -> PreemptionBound
$cnegate :: PreemptionBound -> PreemptionBound
* :: PreemptionBound -> PreemptionBound -> PreemptionBound
$c* :: PreemptionBound -> PreemptionBound -> PreemptionBound
- :: PreemptionBound -> PreemptionBound -> PreemptionBound
$c- :: PreemptionBound -> PreemptionBound -> PreemptionBound
+ :: PreemptionBound -> PreemptionBound -> PreemptionBound
$c+ :: PreemptionBound -> PreemptionBound -> PreemptionBound
Num, Num PreemptionBound
Ord PreemptionBound
PreemptionBound -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
toRational :: PreemptionBound -> Rational
$ctoRational :: PreemptionBound -> Rational
Real, Enum PreemptionBound
Real PreemptionBound
PreemptionBound -> Integer
PreemptionBound
-> PreemptionBound -> (PreemptionBound, PreemptionBound)
PreemptionBound -> PreemptionBound -> PreemptionBound
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
toInteger :: PreemptionBound -> Integer
$ctoInteger :: PreemptionBound -> Integer
divMod :: PreemptionBound
-> PreemptionBound -> (PreemptionBound, PreemptionBound)
$cdivMod :: PreemptionBound
-> PreemptionBound -> (PreemptionBound, PreemptionBound)
quotRem :: PreemptionBound
-> PreemptionBound -> (PreemptionBound, PreemptionBound)
$cquotRem :: PreemptionBound
-> PreemptionBound -> (PreemptionBound, PreemptionBound)
mod :: PreemptionBound -> PreemptionBound -> PreemptionBound
$cmod :: PreemptionBound -> PreemptionBound -> PreemptionBound
div :: PreemptionBound -> PreemptionBound -> PreemptionBound
$cdiv :: PreemptionBound -> PreemptionBound -> PreemptionBound
rem :: PreemptionBound -> PreemptionBound -> PreemptionBound
$crem :: PreemptionBound -> PreemptionBound -> PreemptionBound
quot :: PreemptionBound -> PreemptionBound -> PreemptionBound
$cquot :: PreemptionBound -> PreemptionBound -> PreemptionBound
Integral, ReadPrec [PreemptionBound]
ReadPrec PreemptionBound
Int -> ReadS PreemptionBound
ReadS [PreemptionBound]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PreemptionBound]
$creadListPrec :: ReadPrec [PreemptionBound]
readPrec :: ReadPrec PreemptionBound
$creadPrec :: ReadPrec PreemptionBound
readList :: ReadS [PreemptionBound]
$creadList :: ReadS [PreemptionBound]
readsPrec :: Int -> ReadS PreemptionBound
$creadsPrec :: Int -> ReadS PreemptionBound
Read, Int -> PreemptionBound -> ShowS
[PreemptionBound] -> ShowS
PreemptionBound -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PreemptionBound] -> ShowS
$cshowList :: [PreemptionBound] -> ShowS
show :: PreemptionBound -> String
$cshow :: PreemptionBound -> String
showsPrec :: Int -> PreemptionBound -> ShowS
$cshowsPrec :: Int -> PreemptionBound -> ShowS
Show)
deriving instance Generic PreemptionBound
instance NFData PreemptionBound
newtype FairBound = FairBound Int
deriving (Int -> FairBound
FairBound -> Int
FairBound -> [FairBound]
FairBound -> FairBound
FairBound -> FairBound -> [FairBound]
FairBound -> FairBound -> FairBound -> [FairBound]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: FairBound -> FairBound -> FairBound -> [FairBound]
$cenumFromThenTo :: FairBound -> FairBound -> FairBound -> [FairBound]
enumFromTo :: FairBound -> FairBound -> [FairBound]
$cenumFromTo :: FairBound -> FairBound -> [FairBound]
enumFromThen :: FairBound -> FairBound -> [FairBound]
$cenumFromThen :: FairBound -> FairBound -> [FairBound]
enumFrom :: FairBound -> [FairBound]
$cenumFrom :: FairBound -> [FairBound]
fromEnum :: FairBound -> Int
$cfromEnum :: FairBound -> Int
toEnum :: Int -> FairBound
$ctoEnum :: Int -> FairBound
pred :: FairBound -> FairBound
$cpred :: FairBound -> FairBound
succ :: FairBound -> FairBound
$csucc :: FairBound -> FairBound
Enum, FairBound -> FairBound -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FairBound -> FairBound -> Bool
$c/= :: FairBound -> FairBound -> Bool
== :: FairBound -> FairBound -> Bool
$c== :: FairBound -> FairBound -> Bool
Eq, Eq FairBound
FairBound -> FairBound -> Bool
FairBound -> FairBound -> Ordering
FairBound -> FairBound -> FairBound
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: FairBound -> FairBound -> FairBound
$cmin :: FairBound -> FairBound -> FairBound
max :: FairBound -> FairBound -> FairBound
$cmax :: FairBound -> FairBound -> FairBound
>= :: FairBound -> FairBound -> Bool
$c>= :: FairBound -> FairBound -> Bool
> :: FairBound -> FairBound -> Bool
$c> :: FairBound -> FairBound -> Bool
<= :: FairBound -> FairBound -> Bool
$c<= :: FairBound -> FairBound -> Bool
< :: FairBound -> FairBound -> Bool
$c< :: FairBound -> FairBound -> Bool
compare :: FairBound -> FairBound -> Ordering
$ccompare :: FairBound -> FairBound -> Ordering
Ord, Integer -> FairBound
FairBound -> FairBound
FairBound -> FairBound -> FairBound
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> FairBound
$cfromInteger :: Integer -> FairBound
signum :: FairBound -> FairBound
$csignum :: FairBound -> FairBound
abs :: FairBound -> FairBound
$cabs :: FairBound -> FairBound
negate :: FairBound -> FairBound
$cnegate :: FairBound -> FairBound
* :: FairBound -> FairBound -> FairBound
$c* :: FairBound -> FairBound -> FairBound
- :: FairBound -> FairBound -> FairBound
$c- :: FairBound -> FairBound -> FairBound
+ :: FairBound -> FairBound -> FairBound
$c+ :: FairBound -> FairBound -> FairBound
Num, Num FairBound
Ord FairBound
FairBound -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
toRational :: FairBound -> Rational
$ctoRational :: FairBound -> Rational
Real, Enum FairBound
Real FairBound
FairBound -> Integer
FairBound -> FairBound -> (FairBound, FairBound)
FairBound -> FairBound -> FairBound
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
toInteger :: FairBound -> Integer
$ctoInteger :: FairBound -> Integer
divMod :: FairBound -> FairBound -> (FairBound, FairBound)
$cdivMod :: FairBound -> FairBound -> (FairBound, FairBound)
quotRem :: FairBound -> FairBound -> (FairBound, FairBound)
$cquotRem :: FairBound -> FairBound -> (FairBound, FairBound)
mod :: FairBound -> FairBound -> FairBound
$cmod :: FairBound -> FairBound -> FairBound
div :: FairBound -> FairBound -> FairBound
$cdiv :: FairBound -> FairBound -> FairBound
rem :: FairBound -> FairBound -> FairBound
$crem :: FairBound -> FairBound -> FairBound
quot :: FairBound -> FairBound -> FairBound
$cquot :: FairBound -> FairBound -> FairBound
Integral, ReadPrec [FairBound]
ReadPrec FairBound
Int -> ReadS FairBound
ReadS [FairBound]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FairBound]
$creadListPrec :: ReadPrec [FairBound]
readPrec :: ReadPrec FairBound
$creadPrec :: ReadPrec FairBound
readList :: ReadS [FairBound]
$creadList :: ReadS [FairBound]
readsPrec :: Int -> ReadS FairBound
$creadsPrec :: Int -> ReadS FairBound
Read, Int -> FairBound -> ShowS
[FairBound] -> ShowS
FairBound -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FairBound] -> ShowS
$cshowList :: [FairBound] -> ShowS
show :: FairBound -> String
$cshow :: FairBound -> String
showsPrec :: Int -> FairBound -> ShowS
$cshowsPrec :: Int -> FairBound -> ShowS
Show)
deriving instance Generic FairBound
instance NFData FairBound
newtype LengthBound = LengthBound Int
deriving (Int -> LengthBound
LengthBound -> Int
LengthBound -> [LengthBound]
LengthBound -> LengthBound
LengthBound -> LengthBound -> [LengthBound]
LengthBound -> LengthBound -> LengthBound -> [LengthBound]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: LengthBound -> LengthBound -> LengthBound -> [LengthBound]
$cenumFromThenTo :: LengthBound -> LengthBound -> LengthBound -> [LengthBound]
enumFromTo :: LengthBound -> LengthBound -> [LengthBound]
$cenumFromTo :: LengthBound -> LengthBound -> [LengthBound]
enumFromThen :: LengthBound -> LengthBound -> [LengthBound]
$cenumFromThen :: LengthBound -> LengthBound -> [LengthBound]
enumFrom :: LengthBound -> [LengthBound]
$cenumFrom :: LengthBound -> [LengthBound]
fromEnum :: LengthBound -> Int
$cfromEnum :: LengthBound -> Int
toEnum :: Int -> LengthBound
$ctoEnum :: Int -> LengthBound
pred :: LengthBound -> LengthBound
$cpred :: LengthBound -> LengthBound
succ :: LengthBound -> LengthBound
$csucc :: LengthBound -> LengthBound
Enum, LengthBound -> LengthBound -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LengthBound -> LengthBound -> Bool
$c/= :: LengthBound -> LengthBound -> Bool
== :: LengthBound -> LengthBound -> Bool
$c== :: LengthBound -> LengthBound -> Bool
Eq, Eq LengthBound
LengthBound -> LengthBound -> Bool
LengthBound -> LengthBound -> Ordering
LengthBound -> LengthBound -> LengthBound
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: LengthBound -> LengthBound -> LengthBound
$cmin :: LengthBound -> LengthBound -> LengthBound
max :: LengthBound -> LengthBound -> LengthBound
$cmax :: LengthBound -> LengthBound -> LengthBound
>= :: LengthBound -> LengthBound -> Bool
$c>= :: LengthBound -> LengthBound -> Bool
> :: LengthBound -> LengthBound -> Bool
$c> :: LengthBound -> LengthBound -> Bool
<= :: LengthBound -> LengthBound -> Bool
$c<= :: LengthBound -> LengthBound -> Bool
< :: LengthBound -> LengthBound -> Bool
$c< :: LengthBound -> LengthBound -> Bool
compare :: LengthBound -> LengthBound -> Ordering
$ccompare :: LengthBound -> LengthBound -> Ordering
Ord, Integer -> LengthBound
LengthBound -> LengthBound
LengthBound -> LengthBound -> LengthBound
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> LengthBound
$cfromInteger :: Integer -> LengthBound
signum :: LengthBound -> LengthBound
$csignum :: LengthBound -> LengthBound
abs :: LengthBound -> LengthBound
$cabs :: LengthBound -> LengthBound
negate :: LengthBound -> LengthBound
$cnegate :: LengthBound -> LengthBound
* :: LengthBound -> LengthBound -> LengthBound
$c* :: LengthBound -> LengthBound -> LengthBound
- :: LengthBound -> LengthBound -> LengthBound
$c- :: LengthBound -> LengthBound -> LengthBound
+ :: LengthBound -> LengthBound -> LengthBound
$c+ :: LengthBound -> LengthBound -> LengthBound
Num, Num LengthBound
Ord LengthBound
LengthBound -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
toRational :: LengthBound -> Rational
$ctoRational :: LengthBound -> Rational
Real, Enum LengthBound
Real LengthBound
LengthBound -> Integer
LengthBound -> LengthBound -> (LengthBound, LengthBound)
LengthBound -> LengthBound -> LengthBound
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
toInteger :: LengthBound -> Integer
$ctoInteger :: LengthBound -> Integer
divMod :: LengthBound -> LengthBound -> (LengthBound, LengthBound)
$cdivMod :: LengthBound -> LengthBound -> (LengthBound, LengthBound)
quotRem :: LengthBound -> LengthBound -> (LengthBound, LengthBound)
$cquotRem :: LengthBound -> LengthBound -> (LengthBound, LengthBound)
mod :: LengthBound -> LengthBound -> LengthBound
$cmod :: LengthBound -> LengthBound -> LengthBound
div :: LengthBound -> LengthBound -> LengthBound
$cdiv :: LengthBound -> LengthBound -> LengthBound
rem :: LengthBound -> LengthBound -> LengthBound
$crem :: LengthBound -> LengthBound -> LengthBound
quot :: LengthBound -> LengthBound -> LengthBound
$cquot :: LengthBound -> LengthBound -> LengthBound
Integral, ReadPrec [LengthBound]
ReadPrec LengthBound
Int -> ReadS LengthBound
ReadS [LengthBound]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LengthBound]
$creadListPrec :: ReadPrec [LengthBound]
readPrec :: ReadPrec LengthBound
$creadPrec :: ReadPrec LengthBound
readList :: ReadS [LengthBound]
$creadList :: ReadS [LengthBound]
readsPrec :: Int -> ReadS LengthBound
$creadsPrec :: Int -> ReadS LengthBound
Read, Int -> LengthBound -> ShowS
[LengthBound] -> ShowS
LengthBound -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LengthBound] -> ShowS
$cshowList :: [LengthBound] -> ShowS
show :: LengthBound -> String
$cshow :: LengthBound -> String
showsPrec :: Int -> LengthBound -> ShowS
$cshowsPrec :: Int -> LengthBound -> ShowS
Show)
deriving instance Generic LengthBound
instance NFData LengthBound
data Discard
= DiscardTrace
| DiscardResultAndTrace
deriving (Discard -> Discard -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Discard -> Discard -> Bool
$c/= :: Discard -> Discard -> Bool
== :: Discard -> Discard -> Bool
$c== :: Discard -> Discard -> Bool
Eq, Int -> Discard -> ShowS
[Discard] -> ShowS
Discard -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Discard] -> ShowS
$cshowList :: [Discard] -> ShowS
show :: Discard -> String
$cshow :: Discard -> String
showsPrec :: Int -> Discard -> ShowS
$cshowsPrec :: Int -> Discard -> ShowS
Show, ReadPrec [Discard]
ReadPrec Discard
Int -> ReadS Discard
ReadS [Discard]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Discard]
$creadListPrec :: ReadPrec [Discard]
readPrec :: ReadPrec Discard
$creadPrec :: ReadPrec Discard
readList :: ReadS [Discard]
$creadList :: ReadS [Discard]
readsPrec :: Int -> ReadS Discard
$creadsPrec :: Int -> ReadS Discard
Read, Eq Discard
Discard -> Discard -> Bool
Discard -> Discard -> Ordering
Discard -> Discard -> Discard
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Discard -> Discard -> Discard
$cmin :: Discard -> Discard -> Discard
max :: Discard -> Discard -> Discard
$cmax :: Discard -> Discard -> Discard
>= :: Discard -> Discard -> Bool
$c>= :: Discard -> Discard -> Bool
> :: Discard -> Discard -> Bool
$c> :: Discard -> Discard -> Bool
<= :: Discard -> Discard -> Bool
$c<= :: Discard -> Discard -> Bool
< :: Discard -> Discard -> Bool
$c< :: Discard -> Discard -> Bool
compare :: Discard -> Discard -> Ordering
$ccompare :: Discard -> Discard -> Ordering
Ord, Int -> Discard
Discard -> Int
Discard -> [Discard]
Discard -> Discard
Discard -> Discard -> [Discard]
Discard -> Discard -> Discard -> [Discard]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Discard -> Discard -> Discard -> [Discard]
$cenumFromThenTo :: Discard -> Discard -> Discard -> [Discard]
enumFromTo :: Discard -> Discard -> [Discard]
$cenumFromTo :: Discard -> Discard -> [Discard]
enumFromThen :: Discard -> Discard -> [Discard]
$cenumFromThen :: Discard -> Discard -> [Discard]
enumFrom :: Discard -> [Discard]
$cenumFrom :: Discard -> [Discard]
fromEnum :: Discard -> Int
$cfromEnum :: Discard -> Int
toEnum :: Int -> Discard
$ctoEnum :: Int -> Discard
pred :: Discard -> Discard
$cpred :: Discard -> Discard
succ :: Discard -> Discard
$csucc :: Discard -> Discard
Enum, Discard
forall a. a -> a -> Bounded a
maxBound :: Discard
$cmaxBound :: Discard
minBound :: Discard
$cminBound :: Discard
Bounded)
deriving instance Generic Discard
instance NFData Discard
newtype Weaken a = Weaken
{ forall a. Weaken a -> Either Condition a -> Maybe Discard
getWeakDiscarder :: Either Condition a -> Maybe Discard }
instance Semigroup (Weaken a) where
<> :: Weaken a -> Weaken a -> Weaken a
(<>) = forall (f :: * -> *) a b c.
Divisible f =>
(a -> (b, c)) -> f b -> f c -> f a
divide (\a
efa -> (a
efa, a
efa))
instance Monoid (Weaken a) where
mempty :: Weaken a
mempty = forall (f :: * -> *) a. Divisible f => f a
conquer
mappend :: Weaken a -> Weaken a -> Weaken a
mappend = forall a. Semigroup a => a -> a -> a
(<>)
instance Contravariant Weaken where
contramap :: forall a' a. (a' -> a) -> Weaken a -> Weaken a'
contramap a' -> a
f (Weaken Either Condition a -> Maybe Discard
d) = forall a. (Either Condition a -> Maybe Discard) -> Weaken a
Weaken (Either Condition a -> Maybe Discard
d forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a' -> a
f)
instance Divisible Weaken where
divide :: forall a b c. (a -> (b, c)) -> Weaken b -> Weaken c -> Weaken a
divide a -> (b, c)
f (Weaken Either Condition b -> Maybe Discard
d1) (Weaken Either Condition c -> Maybe Discard
d2) = forall a. (Either Condition a -> Maybe Discard) -> Weaken a
Weaken forall a b. (a -> b) -> a -> b
$ \case
Right a
a ->
let (b
b, c
c) = a -> (b, c)
f a
a
in forall a. Ord a => a -> a -> a
min (Either Condition b -> Maybe Discard
d1 (forall a b. b -> Either a b
Right b
b)) (Either Condition c -> Maybe Discard
d2 (forall a b. b -> Either a b
Right c
c))
Left Condition
e -> forall a. Ord a => a -> a -> a
min (Either Condition b -> Maybe Discard
d1 (forall a b. a -> Either a b
Left Condition
e)) (Either Condition c -> Maybe Discard
d2 (forall a b. a -> Either a b
Left Condition
e))
conquer :: forall a. Weaken a
conquer = forall a. (Either Condition a -> Maybe Discard) -> Weaken a
Weaken (forall a b. a -> b -> a
const (forall a. a -> Maybe a
Just Discard
DiscardResultAndTrace))
weakenDiscard ::
(Either Condition a -> Maybe Discard)
-> (Either Condition a -> Maybe Discard)
-> Either Condition a -> Maybe Discard
weakenDiscard :: forall a.
(Either Condition a -> Maybe Discard)
-> (Either Condition a -> Maybe Discard)
-> Either Condition a
-> Maybe Discard
weakenDiscard Either Condition a -> Maybe Discard
d1 Either Condition a -> Maybe Discard
d2 =
forall a. Weaken a -> Either Condition a -> Maybe Discard
getWeakDiscarder (forall a. (Either Condition a -> Maybe Discard) -> Weaken a
Weaken Either Condition a -> Maybe Discard
d1 forall a. Semigroup a => a -> a -> a
<> forall a. (Either Condition a -> Maybe Discard) -> Weaken a
Weaken Either Condition a -> Maybe Discard
d2)
newtype Strengthen a = Strengthen
{ forall a. Strengthen a -> Either Condition a -> Maybe Discard
getStrongDiscarder :: Either Condition a -> Maybe Discard }
instance Semigroup (Strengthen a) where
<> :: Strengthen a -> Strengthen a -> Strengthen a
(<>) = forall (f :: * -> *) a b c.
Divisible f =>
(a -> (b, c)) -> f b -> f c -> f a
divide (\a
efa -> (a
efa, a
efa))
instance Monoid (Strengthen a) where
mempty :: Strengthen a
mempty = forall (f :: * -> *) a. Divisible f => f a
conquer
mappend :: Strengthen a -> Strengthen a -> Strengthen a
mappend = forall a. Semigroup a => a -> a -> a
(<>)
instance Contravariant Strengthen where
contramap :: forall a' a. (a' -> a) -> Strengthen a -> Strengthen a'
contramap a' -> a
f (Strengthen Either Condition a -> Maybe Discard
d) = forall a. (Either Condition a -> Maybe Discard) -> Strengthen a
Strengthen (Either Condition a -> Maybe Discard
d forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a' -> a
f)
instance Divisible Strengthen where
divide :: forall a b c.
(a -> (b, c)) -> Strengthen b -> Strengthen c -> Strengthen a
divide a -> (b, c)
f (Strengthen Either Condition b -> Maybe Discard
d1) (Strengthen Either Condition c -> Maybe Discard
d2) = forall a. (Either Condition a -> Maybe Discard) -> Strengthen a
Strengthen forall a b. (a -> b) -> a -> b
$ \case
Right a
a ->
let (b
b, c
c) = a -> (b, c)
f a
a
in forall a. Ord a => a -> a -> a
max (Either Condition b -> Maybe Discard
d1 (forall a b. b -> Either a b
Right b
b)) (Either Condition c -> Maybe Discard
d2 (forall a b. b -> Either a b
Right c
c))
Left Condition
e -> forall a. Ord a => a -> a -> a
max (Either Condition b -> Maybe Discard
d1 (forall a b. a -> Either a b
Left Condition
e)) (Either Condition c -> Maybe Discard
d2 (forall a b. a -> Either a b
Left Condition
e))
conquer :: forall a. Strengthen a
conquer = forall a. (Either Condition a -> Maybe Discard) -> Strengthen a
Strengthen (forall a b. a -> b -> a
const forall a. Maybe a
Nothing)
strengthenDiscard ::
(Either Condition a -> Maybe Discard)
-> (Either Condition a -> Maybe Discard)
-> Either Condition a -> Maybe Discard
strengthenDiscard :: forall a.
(Either Condition a -> Maybe Discard)
-> (Either Condition a -> Maybe Discard)
-> Either Condition a
-> Maybe Discard
strengthenDiscard Either Condition a -> Maybe Discard
d1 Either Condition a -> Maybe Discard
d2 =
forall a. Strengthen a -> Either Condition a -> Maybe Discard
getStrongDiscarder (forall a. (Either Condition a -> Maybe Discard) -> Strengthen a
Strengthen Either Condition a -> Maybe Discard
d1 forall a. Semigroup a => a -> a -> a
<> forall a. (Either Condition a -> Maybe Discard) -> Strengthen a
Strengthen Either Condition a -> Maybe Discard
d2)
data MemType =
SequentialConsistency
| TotalStoreOrder
| PartialStoreOrder
deriving (MemType -> MemType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MemType -> MemType -> Bool
$c/= :: MemType -> MemType -> Bool
== :: MemType -> MemType -> Bool
$c== :: MemType -> MemType -> Bool
Eq, Int -> MemType -> ShowS
[MemType] -> ShowS
MemType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MemType] -> ShowS
$cshowList :: [MemType] -> ShowS
show :: MemType -> String
$cshow :: MemType -> String
showsPrec :: Int -> MemType -> ShowS
$cshowsPrec :: Int -> MemType -> ShowS
Show, ReadPrec [MemType]
ReadPrec MemType
Int -> ReadS MemType
ReadS [MemType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MemType]
$creadListPrec :: ReadPrec [MemType]
readPrec :: ReadPrec MemType
$creadPrec :: ReadPrec MemType
readList :: ReadS [MemType]
$creadList :: ReadS [MemType]
readsPrec :: Int -> ReadS MemType
$creadsPrec :: Int -> ReadS MemType
Read, Eq MemType
MemType -> MemType -> Bool
MemType -> MemType -> Ordering
MemType -> MemType -> MemType
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: MemType -> MemType -> MemType
$cmin :: MemType -> MemType -> MemType
max :: MemType -> MemType -> MemType
$cmax :: MemType -> MemType -> MemType
>= :: MemType -> MemType -> Bool
$c>= :: MemType -> MemType -> Bool
> :: MemType -> MemType -> Bool
$c> :: MemType -> MemType -> Bool
<= :: MemType -> MemType -> Bool
$c<= :: MemType -> MemType -> Bool
< :: MemType -> MemType -> Bool
$c< :: MemType -> MemType -> Bool
compare :: MemType -> MemType -> Ordering
$ccompare :: MemType -> MemType -> Ordering
Ord, Int -> MemType
MemType -> Int
MemType -> [MemType]
MemType -> MemType
MemType -> MemType -> [MemType]
MemType -> MemType -> MemType -> [MemType]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: MemType -> MemType -> MemType -> [MemType]
$cenumFromThenTo :: MemType -> MemType -> MemType -> [MemType]
enumFromTo :: MemType -> MemType -> [MemType]
$cenumFromTo :: MemType -> MemType -> [MemType]
enumFromThen :: MemType -> MemType -> [MemType]
$cenumFromThen :: MemType -> MemType -> [MemType]
enumFrom :: MemType -> [MemType]
$cenumFrom :: MemType -> [MemType]
fromEnum :: MemType -> Int
$cfromEnum :: MemType -> Int
toEnum :: Int -> MemType
$ctoEnum :: Int -> MemType
pred :: MemType -> MemType
$cpred :: MemType -> MemType
succ :: MemType -> MemType
$csucc :: MemType -> MemType
Enum, MemType
forall a. a -> a -> Bounded a
maxBound :: MemType
$cmaxBound :: MemType
minBound :: MemType
$cminBound :: MemType
Bounded)
deriving instance Generic MemType
instance NFData MemType
newtype MonadFailException = MonadFailException String
deriving Int -> MonadFailException -> ShowS
[MonadFailException] -> ShowS
MonadFailException -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MonadFailException] -> ShowS
$cshowList :: [MonadFailException] -> ShowS
show :: MonadFailException -> String
$cshow :: MonadFailException -> String
showsPrec :: Int -> MonadFailException -> ShowS
$cshowsPrec :: Int -> MonadFailException -> ShowS
Show
instance Exception MonadFailException
deriving instance Generic MonadFailException
instance NFData MonadFailException
data ConcurrencyState = ConcurrencyState
{ ConcurrencyState -> Map IORefId Int
concIOState :: Map IORefId Int
, ConcurrencyState -> Set MVarId
concMVState :: Set MVarId
, ConcurrencyState -> Map ThreadId MaskingState
concMaskState :: Map ThreadId MaskingState
} deriving (ConcurrencyState -> ConcurrencyState -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConcurrencyState -> ConcurrencyState -> Bool
$c/= :: ConcurrencyState -> ConcurrencyState -> Bool
== :: ConcurrencyState -> ConcurrencyState -> Bool
$c== :: ConcurrencyState -> ConcurrencyState -> Bool
Eq, Int -> ConcurrencyState -> ShowS
[ConcurrencyState] -> ShowS
ConcurrencyState -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConcurrencyState] -> ShowS
$cshowList :: [ConcurrencyState] -> ShowS
show :: ConcurrencyState -> String
$cshow :: ConcurrencyState -> String
showsPrec :: Int -> ConcurrencyState -> ShowS
$cshowsPrec :: Int -> ConcurrencyState -> ShowS
Show)
instance NFData ConcurrencyState where
rnf :: ConcurrencyState -> ()
rnf ConcurrencyState
cstate = forall a. NFData a => a -> ()
rnf
( ConcurrencyState -> Map IORefId Int
concIOState ConcurrencyState
cstate
, ConcurrencyState -> Set MVarId
concMVState ConcurrencyState
cstate
, [(ThreadId
t, forall a. Show a => a -> String
show MaskingState
m) | (ThreadId
t, MaskingState
m) <- forall k a. Map k a -> [(k, a)]
M.toList (ConcurrencyState -> Map ThreadId MaskingState
concMaskState ConcurrencyState
cstate)]
)
isBuffered :: ConcurrencyState -> IORefId -> Bool
isBuffered :: ConcurrencyState -> IORefId -> Bool
isBuffered ConcurrencyState
cstate IORefId
r = ConcurrencyState -> IORefId -> Int
numBuffered ConcurrencyState
cstate IORefId
r forall a. Eq a => a -> a -> Bool
/= Int
0
numBuffered :: ConcurrencyState -> IORefId -> Int
numBuffered :: ConcurrencyState -> IORefId -> Int
numBuffered ConcurrencyState
cstate IORefId
r = forall k a. Ord k => a -> k -> Map k a -> a
M.findWithDefault Int
0 IORefId
r (ConcurrencyState -> Map IORefId Int
concIOState ConcurrencyState
cstate)
isFull :: ConcurrencyState -> MVarId -> Bool
isFull :: ConcurrencyState -> MVarId -> Bool
isFull ConcurrencyState
cstate MVarId
v = forall a. Ord a => a -> Set a -> Bool
S.member MVarId
v (ConcurrencyState -> Set MVarId
concMVState ConcurrencyState
cstate)
canInterrupt :: ConcurrencyState -> ThreadId -> ThreadAction -> Bool
canInterrupt :: ConcurrencyState -> ThreadId -> ThreadAction -> Bool
canInterrupt ConcurrencyState
cstate ThreadId
tid ThreadAction
act
| ConcurrencyState -> ThreadId -> Bool
isMaskedInterruptible ConcurrencyState
cstate ThreadId
tid = case ThreadAction
act of
BlockedPutMVar MVarId
_ -> Bool
True
BlockedReadMVar MVarId
_ -> Bool
True
BlockedTakeMVar MVarId
_ -> Bool
True
BlockedSTM [TAction]
_ -> Bool
True
BlockedThrowTo ThreadId
_ -> Bool
True
ThreadAction
_ -> Bool
False
| ConcurrencyState -> ThreadId -> Bool
isMaskedUninterruptible ConcurrencyState
cstate ThreadId
tid = Bool
False
| Bool
otherwise = Bool
True
canInterruptL :: ConcurrencyState -> ThreadId -> Lookahead -> Bool
canInterruptL :: ConcurrencyState -> ThreadId -> Lookahead -> Bool
canInterruptL ConcurrencyState
cstate ThreadId
tid Lookahead
lh
| ConcurrencyState -> ThreadId -> Bool
isMaskedInterruptible ConcurrencyState
cstate ThreadId
tid = case Lookahead
lh of
WillPutMVar MVarId
_ -> Bool
True
WillReadMVar MVarId
_ -> Bool
True
WillTakeMVar MVarId
_ -> Bool
True
Lookahead
WillSTM -> Bool
True
WillThrowTo ThreadId
_ -> Bool
True
Lookahead
_ -> Bool
False
| ConcurrencyState -> ThreadId -> Bool
isMaskedUninterruptible ConcurrencyState
cstate ThreadId
tid = Bool
False
| Bool
otherwise = Bool
True
isMaskedInterruptible :: ConcurrencyState -> ThreadId -> Bool
isMaskedInterruptible :: ConcurrencyState -> ThreadId -> Bool
isMaskedInterruptible ConcurrencyState
cstate ThreadId
tid =
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup ThreadId
tid (ConcurrencyState -> Map ThreadId MaskingState
concMaskState ConcurrencyState
cstate) forall a. Eq a => a -> a -> Bool
== forall a. a -> Maybe a
Just MaskingState
MaskedInterruptible
isMaskedUninterruptible :: ConcurrencyState -> ThreadId -> Bool
isMaskedUninterruptible :: ConcurrencyState -> ThreadId -> Bool
isMaskedUninterruptible ConcurrencyState
cstate ThreadId
tid =
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup ThreadId
tid (ConcurrencyState -> Map ThreadId MaskingState
concMaskState ConcurrencyState
cstate) forall a. Eq a => a -> a -> Bool
== forall a. a -> Maybe a
Just MaskingState
MaskedUninterruptible