File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
io-classes/src/Control/Monad/Class
io-sim/src/Control/Monad/IOSim Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -186,7 +186,14 @@ class MonadCatch m => MonadMask m where
186
186
187
187
188
188
class MonadMask m => MonadMaskingState m where
189
+ {-# MINIMAL getMaskingState, interruptible #-}
189
190
getMaskingState :: m MaskingState
191
+ interruptible :: m a -> m a
192
+ allowInterrupt :: m ()
193
+
194
+ allowInterrupt = interruptible (return () )
195
+
196
+
190
197
191
198
-- | Monads which can 'evaluate'.
192
199
--
@@ -230,6 +237,8 @@ instance MonadMask IO where
230
237
231
238
instance MonadMaskingState IO where
232
239
getMaskingState = IO. getMaskingState
240
+ interruptible = IO. interruptible
241
+ allowInterrupt = IO. allowInterrupt
233
242
234
243
instance MonadEvaluate IO where
235
244
evaluate = IO. evaluate
Original file line number Diff line number Diff line change @@ -339,6 +339,12 @@ instance MonadMask (IOSim s) where
339
339
340
340
instance MonadMaskingState (IOSim s ) where
341
341
getMaskingState = getMaskingStateImpl
342
+ interruptible action = do
343
+ b <- getMaskingStateImpl
344
+ case b of
345
+ Unmasked -> action
346
+ MaskedInterruptible -> unblock action
347
+ MaskedUninterruptible -> action
342
348
343
349
instance Exceptions. MonadMask (IOSim s ) where
344
350
mask = MonadThrow. mask
You can’t perform that action at this time.
0 commit comments