Skip to content

Commit 90a9594

Browse files
committed
io-sim: updated
1 parent 6a16ecd commit 90a9594

File tree

1 file changed

+19
-23
lines changed

1 file changed

+19
-23
lines changed

io-sim/src/Control/Monad/IOSim/Internal.hs

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,21 @@ instance MonadFork (IOSim s) where
349349
instance MonadSay (STMSim s) where
350350
say msg = STM $ \k -> SayStm msg (k ())
351351

352-
instance MonadSTMTx (STM s) where
353-
type TVar_ (STM s) = TVar s
354-
type TMVar_ (STM s) = TMVarDefault (IOSim s)
355-
type TQueue_ (STM s) = TQueueDefault (IOSim s)
356-
type TBQueue_ (STM s) = TBQueueDefault (IOSim s)
352+
353+
instance MonadLabelledSTM (IOSim s) where
354+
labelTVar tvar label = STM $ \k -> LabelTVar label tvar (k ())
355+
labelTMVar = labelTMVarDefault
356+
labelTQueue = labelTQueueDefault
357+
labelTBQueue = labelTBQueueDefault
358+
359+
instance MonadSTM (IOSim s) where
360+
type STM (IOSim s) = STM s
361+
type TVar (IOSim s) = TVar s
362+
type TMVar (IOSim s) = TMVarDefault (IOSim s)
363+
type TQueue (IOSim s) = TQueueDefault (IOSim s)
364+
type TBQueue (IOSim s) = TBQueueDefault (IOSim s)
365+
366+
atomically action = IOSim $ \k -> Atomically action k
357367

358368
newTVar x = STM $ \k -> NewTVar Nothing x k
359369
readTVar tvar = STM $ \k -> ReadTVar tvar k
@@ -391,19 +401,6 @@ instance MonadSTMTx (STM s) where
391401
isEmptyTBQueue = isEmptyTBQueueDefault
392402
isFullTBQueue = isFullTBQueueDefault
393403

394-
instance MonadLabelledSTMTx (STM s) where
395-
labelTVar tvar label = STM $ \k -> LabelTVar label tvar (k ())
396-
labelTMVar = labelTMVarDefault
397-
labelTQueue = labelTQueueDefault
398-
labelTBQueue = labelTBQueueDefault
399-
400-
instance MonadLabelledSTM (IOSim s) where
401-
402-
instance MonadSTM (IOSim s) where
403-
type STM (IOSim s) = STM s
404-
405-
atomically action = IOSim $ \k -> Atomically action k
406-
407404
newTMVarIO = newTMVarIODefault
408405
newEmptyTMVarIO = newEmptyTMVarIODefault
409406

@@ -418,10 +415,6 @@ instance Ord (Async s a) where
418415
instance Functor (Async s) where
419416
fmap f (Async tid a) = Async tid (fmap f <$> a)
420417

421-
instance MonadAsyncSTM (Async s) (STM s) where
422-
waitCatchSTM (Async _ w) = w
423-
pollSTM (Async _ w) = (Just <$> w) `orElse` return Nothing
424-
425418
instance MonadAsync (IOSim s) where
426419
type Async (IOSim s) = Async s
427420

@@ -432,7 +425,10 @@ instance MonadAsync (IOSim s) where
432425
labelTMVarIO var ("async-" ++ show tid)
433426
return (Async tid (readTMVar var))
434427

435-
asyncThreadId _proxy (Async tid _) = tid
428+
asyncThreadId (Async tid _) = tid
429+
430+
waitCatchSTM (Async _ w) = w
431+
pollSTM (Async _ w) = (Just <$> w) `orElse` return Nothing
436432

437433
cancel a@(Async tid _) = throwTo tid AsyncCancelled <* waitCatch a
438434
cancelWith a@(Async tid _) e = throwTo tid e <* waitCatch a

0 commit comments

Comments
 (0)