@@ -457,35 +457,35 @@ tryAll = try
457
457
-- ReaderT instance
458
458
--
459
459
460
- newtype WrappedAsync r (m :: Type -> Type ) a =
461
- WrappedAsync { unWrapAsync :: Async m a }
460
+ newtype AsyncReaderT r (m :: Type -> Type ) a =
461
+ AsyncReaderT { getAsyncReaderT :: Async m a }
462
462
463
463
instance ( MonadAsync m
464
464
, MonadCatch (STM m )
465
465
, MonadFork m
466
466
, MonadMask m
467
467
) => MonadAsync (ReaderT r m ) where
468
- type Async (ReaderT r m ) = WrappedAsync r m
469
- asyncThreadId (WrappedAsync a) = asyncThreadId a
468
+ type Async (ReaderT r m ) = AsyncReaderT r m
469
+ asyncThreadId (AsyncReaderT a) = asyncThreadId a
470
470
471
- async (ReaderT ma) = ReaderT $ \ r -> WrappedAsync <$> async (ma r)
472
- asyncBound (ReaderT ma) = ReaderT $ \ r -> WrappedAsync <$> asyncBound (ma r)
473
- asyncOn n (ReaderT ma) = ReaderT $ \ r -> WrappedAsync <$> asyncOn n (ma r)
471
+ async (ReaderT ma) = ReaderT $ \ r -> AsyncReaderT <$> async (ma r)
472
+ asyncBound (ReaderT ma) = ReaderT $ \ r -> AsyncReaderT <$> asyncBound (ma r)
473
+ asyncOn n (ReaderT ma) = ReaderT $ \ r -> AsyncReaderT <$> asyncOn n (ma r)
474
474
withAsync (ReaderT ma) f = ReaderT $ \ r -> withAsync (ma r)
475
- $ \ a -> runReaderT (f (WrappedAsync a)) r
475
+ $ \ a -> runReaderT (f (AsyncReaderT a)) r
476
476
withAsyncBound (ReaderT ma) f = ReaderT $ \ r -> withAsyncBound (ma r)
477
- $ \ a -> runReaderT (f (WrappedAsync a)) r
477
+ $ \ a -> runReaderT (f (AsyncReaderT a)) r
478
478
withAsyncOn n (ReaderT ma) f = ReaderT $ \ r -> withAsyncOn n (ma r)
479
- $ \ a -> runReaderT (f (WrappedAsync a)) r
479
+ $ \ a -> runReaderT (f (AsyncReaderT a)) r
480
480
481
- asyncWithUnmask f = ReaderT $ \ r -> fmap WrappedAsync
481
+ asyncWithUnmask f = ReaderT $ \ r -> fmap AsyncReaderT
482
482
$ asyncWithUnmask
483
483
$ \ unmask -> runReaderT (f (liftF unmask)) r
484
484
where
485
485
liftF :: (m a -> m a ) -> ReaderT r m a -> ReaderT r m a
486
486
liftF g (ReaderT r) = ReaderT (g . r)
487
487
488
- asyncOnWithUnmask n f = ReaderT $ \ r -> fmap WrappedAsync
488
+ asyncOnWithUnmask n f = ReaderT $ \ r -> fmap AsyncReaderT
489
489
$ asyncOnWithUnmask n
490
490
$ \ unmask -> runReaderT (f (liftF unmask)) r
491
491
where
@@ -495,52 +495,52 @@ instance ( MonadAsync m
495
495
withAsyncWithUnmask action f =
496
496
ReaderT $ \ r -> withAsyncWithUnmask (\ unmask -> case action (liftF unmask) of
497
497
ReaderT ma -> ma r)
498
- $ \ a -> runReaderT (f (WrappedAsync a)) r
498
+ $ \ a -> runReaderT (f (AsyncReaderT a)) r
499
499
where
500
500
liftF :: (m a -> m a ) -> ReaderT r m a -> ReaderT r m a
501
501
liftF g (ReaderT r) = ReaderT (g . r)
502
502
503
503
withAsyncOnWithUnmask n action f =
504
504
ReaderT $ \ r -> withAsyncOnWithUnmask n (\ unmask -> case action (liftF unmask) of
505
505
ReaderT ma -> ma r)
506
- $ \ a -> runReaderT (f (WrappedAsync a)) r
506
+ $ \ a -> runReaderT (f (AsyncReaderT a)) r
507
507
where
508
508
liftF :: (m a -> m a ) -> ReaderT r m a -> ReaderT r m a
509
509
liftF g (ReaderT r) = ReaderT (g . r)
510
510
511
- waitCatchSTM = WrappedSTM . waitCatchSTM . unWrapAsync
512
- pollSTM = WrappedSTM . pollSTM . unWrapAsync
511
+ waitCatchSTM = lift . waitCatchSTM . getAsyncReaderT
512
+ pollSTM = lift . pollSTM . getAsyncReaderT
513
513
514
514
race (ReaderT ma) (ReaderT mb) = ReaderT $ \ r -> race (ma r) (mb r)
515
515
race_ (ReaderT ma) (ReaderT mb) = ReaderT $ \ r -> race_ (ma r) (mb r)
516
516
concurrently (ReaderT ma) (ReaderT mb) = ReaderT $ \ r -> concurrently (ma r) (mb r)
517
517
518
- wait = lift . wait . unWrapAsync
519
- poll = lift . poll . unWrapAsync
520
- waitCatch = lift . waitCatch . unWrapAsync
521
- cancel = lift . cancel . unWrapAsync
518
+ wait = lift . wait . getAsyncReaderT
519
+ poll = lift . poll . getAsyncReaderT
520
+ waitCatch = lift . waitCatch . getAsyncReaderT
521
+ cancel = lift . cancel . getAsyncReaderT
522
522
uninterruptibleCancel = lift . uninterruptibleCancel
523
- . unWrapAsync
523
+ . getAsyncReaderT
524
524
cancelWith = (lift .: cancelWith)
525
- . unWrapAsync
526
- waitAny = fmap (first WrappedAsync )
525
+ . getAsyncReaderT
526
+ waitAny = fmap (first AsyncReaderT )
527
527
. lift . waitAny
528
- . map unWrapAsync
529
- waitAnyCatch = fmap (first WrappedAsync )
528
+ . map getAsyncReaderT
529
+ waitAnyCatch = fmap (first AsyncReaderT )
530
530
. lift . waitAnyCatch
531
- . map unWrapAsync
532
- waitAnyCancel = fmap (first WrappedAsync )
531
+ . map getAsyncReaderT
532
+ waitAnyCancel = fmap (first AsyncReaderT )
533
533
. lift . waitAnyCancel
534
- . map unWrapAsync
535
- waitAnyCatchCancel = fmap (first WrappedAsync )
534
+ . map getAsyncReaderT
535
+ waitAnyCatchCancel = fmap (first AsyncReaderT )
536
536
. lift . waitAnyCatchCancel
537
- . map unWrapAsync
538
- waitEither = on (lift .: waitEither) unWrapAsync
539
- waitEitherCatch = on (lift .: waitEitherCatch) unWrapAsync
540
- waitEitherCancel = on (lift .: waitEitherCancel) unWrapAsync
541
- waitEitherCatchCancel = on (lift .: waitEitherCatchCancel) unWrapAsync
542
- waitEither_ = on (lift .: waitEither_) unWrapAsync
543
- waitBoth = on (lift .: waitBoth) unWrapAsync
537
+ . map getAsyncReaderT
538
+ waitEither = on (lift .: waitEither) getAsyncReaderT
539
+ waitEitherCatch = on (lift .: waitEitherCatch) getAsyncReaderT
540
+ waitEitherCancel = on (lift .: waitEitherCancel) getAsyncReaderT
541
+ waitEitherCatchCancel = on (lift .: waitEitherCatchCancel) getAsyncReaderT
542
+ waitEither_ = on (lift .: waitEither_) getAsyncReaderT
543
+ waitBoth = on (lift .: waitBoth) getAsyncReaderT
544
544
545
545
546
546
--
0 commit comments