From 0ab23a36da3949fb92a1a251a13854fcfb4be610 Mon Sep 17 00:00:00 2001 From: joe Date: Sat, 20 Aug 2016 02:19:25 -0400 Subject: Compatibility with monad-control-1.0. --- src/Network/BitTorrent/Client/Types.hs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/Network/BitTorrent/Client') diff --git a/src/Network/BitTorrent/Client/Types.hs b/src/Network/BitTorrent/Client/Types.hs index 9bae7dc3..7f228276 100644 --- a/src/Network/BitTorrent/Client/Types.hs +++ b/src/Network/BitTorrent/Client/Types.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE MultiParamTypeClasses #-} @@ -106,6 +107,18 @@ newtype BitTorrent a = BitTorrent class MonadBitTorrent m where liftBT :: BitTorrent a -> m a +#if MIN_VERSION_monad_control(1,0,0) +newtype BTStM a = BTStM { unBTSt :: StM (ReaderT Client IO) a } + +instance MonadBaseControl IO BitTorrent where + type StM BitTorrent a = BTStM a + liftBaseWith cc = BitTorrent $ liftBaseWith $ \ cc' -> + cc $ \ (BitTorrent m) -> BTStM <$> cc' m + {-# INLINE liftBaseWith #-} + + restoreM = BitTorrent . restoreM . unBTSt + {-# INLINE restoreM #-} +#else instance MonadBaseControl IO BitTorrent where newtype StM BitTorrent a = StM { unSt :: StM (ReaderT Client IO) a } liftBaseWith cc = BitTorrent $ liftBaseWith $ \ cc' -> @@ -114,6 +127,7 @@ instance MonadBaseControl IO BitTorrent where restoreM = BitTorrent . restoreM . unSt {-# INLINE restoreM #-} +#endif -- | NOP. instance MonadBitTorrent BitTorrent where @@ -146,4 +160,4 @@ runBitTorrent client action = runReaderT (unBitTorrent action) client getClient :: BitTorrent Client getClient = BitTorrent ask -{-# INLINE getClient #-} \ No newline at end of file +{-# INLINE getClient #-} -- cgit v1.2.3