@@ -558,41 +558,9 @@ instance (Monoid a, MonadAsync m) => Monoid (AsyncT m a) where
558 mempty = return mempty
558 mempty = return mempty
560------------------------------------------------------------------------------
560------------------------------------------------------------------------------
562------------------------------------------------------------------------------
562------------------------------------------------------------------------------
564−instance MonadAsync m => MonadIO (AsyncT m) where
565− liftIO mx = AsyncT $ liftIO mx >>= return . Just
567−-------------------------------------------------------------------------------
568−-- AsyncT transformer
569−-------------------------------------------------------------------------------
571−instance MonadTrans AsyncT where
572− lift mx = AsyncT $ lift mx >>= return . Just
574−instance MonadTransControl AsyncT where
575− type StT AsyncT a = (Maybe a, Context)
576− liftWith f = AsyncT $ StateT $ \s ->
577− liftM (\x -> (Just x, s))
578− (f $ \t -> runStateT (runAsyncT t) s)
579− restoreT = AsyncT . StateT . const
580− {-# INLINABLE liftWith #-}
581− {-# INLINABLE restoreT #-}
583−instance (MonadBase b m, MonadAsync m) => MonadBase b (AsyncT m) where
584− liftBase = liftBaseDefault
586−instance (MonadBaseControl b m, MonadAsync m) => MonadBaseControl b (AsyncT m) where
587− type StM (AsyncT m) a = ComposeSt AsyncT m a
588− liftBaseWith = defaultLiftBaseWith
589− restoreM = defaultRestoreM
590− {-# INLINABLE liftBaseWith #-}
591− {-# INLINABLE restoreM #-}
593−instance MonadAsync m => MonadThrow (AsyncT m) where
594− throwM e = lift $ throwM e
596instance (Num a, Monad (AsyncT m)) => Num (AsyncT m a) where
564instance (Num a, Monad (AsyncT m)) => Num (AsyncT m a) where
597 fromInteger = return . fromInteger
565 fromInteger = return . fromInteger
598 mf + mg = (+) <$> mf <*> mg
566 mf + mg = (+) <$> mf <*> mg
@@ -646,3 +614,39 @@ thenDiscard ma mb = AsyncT $ do
646-- | Same as 'thenDiscard'.
614-- | Same as 'thenDiscard'.
647(>>*) :: MonadAsync m => AsyncT m a -> AsyncT m b -> AsyncT m a
615(>>*) :: MonadAsync m => AsyncT m a -> AsyncT m b -> AsyncT m a
648(>>*) = thenDiscard
616(>>*) = thenDiscard
618+------------------------------------------------------------------------------
620+------------------------------------------------------------------------------
622+instance MonadAsync m => MonadIO (AsyncT m) where
623+ liftIO mx = AsyncT $ liftIO mx >>= return . Just
625+-------------------------------------------------------------------------------
626+-- AsyncT transformer
627+-------------------------------------------------------------------------------
629+instance MonadTrans AsyncT where
630+ lift mx = AsyncT $ lift mx >>= return . Just
632+instance MonadTransControl AsyncT where
633+ type StT AsyncT a = (Maybe a, Context)
634+ liftWith f = AsyncT $ StateT $ \s ->
635+ liftM (\x -> (Just x, s))
636+ (f $ \t -> runStateT (runAsyncT t) s)
637+ restoreT = AsyncT . StateT . const
638+ {-# INLINABLE liftWith #-}
639+ {-# INLINABLE restoreT #-}
641+instance (MonadBase b m, MonadAsync m) => MonadBase b (AsyncT m) where
642+ liftBase = liftBaseDefault
644+instance (MonadBaseControl b m, MonadAsync m) => MonadBaseControl b (AsyncT m) where
645+ type StM (AsyncT m) a = ComposeSt AsyncT m a
646+ liftBaseWith = defaultLiftBaseWith
647+ restoreM = defaultRestoreM
648+ {-# INLINABLE liftBaseWith #-}
649+ {-# INLINABLE restoreM #-}
651+instance MonadAsync m => MonadThrow (AsyncT m) where
652+ throwM e = lift $ throwM e