summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Client
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2016-08-20 02:19:25 -0400
committerjoe <joe@jerkface.net>2016-08-20 02:19:25 -0400
commit0ab23a36da3949fb92a1a251a13854fcfb4be610 (patch)
tree2302f7da5303382eb7b834d9683aab59b7c30a02 /src/Network/BitTorrent/Client
parent7e3eb07aeca78004d7a6879ee846f8e349950292 (diff)
Compatibility with monad-control-1.0.
Diffstat (limited to 'src/Network/BitTorrent/Client')
-rw-r--r--src/Network/BitTorrent/Client/Types.hs16
1 files changed, 15 insertions, 1 deletions
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 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE FlexibleInstances #-} 2{-# LANGUAGE FlexibleInstances #-}
2{-# LANGUAGE TypeFamilies #-} 3{-# LANGUAGE TypeFamilies #-}
3{-# LANGUAGE MultiParamTypeClasses #-} 4{-# LANGUAGE MultiParamTypeClasses #-}
@@ -106,6 +107,18 @@ newtype BitTorrent a = BitTorrent
106class MonadBitTorrent m where 107class MonadBitTorrent m where
107 liftBT :: BitTorrent a -> m a 108 liftBT :: BitTorrent a -> m a
108 109
110#if MIN_VERSION_monad_control(1,0,0)
111newtype BTStM a = BTStM { unBTSt :: StM (ReaderT Client IO) a }
112
113instance MonadBaseControl IO BitTorrent where
114 type StM BitTorrent a = BTStM a
115 liftBaseWith cc = BitTorrent $ liftBaseWith $ \ cc' ->
116 cc $ \ (BitTorrent m) -> BTStM <$> cc' m
117 {-# INLINE liftBaseWith #-}
118
119 restoreM = BitTorrent . restoreM . unBTSt
120 {-# INLINE restoreM #-}
121#else
109instance MonadBaseControl IO BitTorrent where 122instance MonadBaseControl IO BitTorrent where
110 newtype StM BitTorrent a = StM { unSt :: StM (ReaderT Client IO) a } 123 newtype StM BitTorrent a = StM { unSt :: StM (ReaderT Client IO) a }
111 liftBaseWith cc = BitTorrent $ liftBaseWith $ \ cc' -> 124 liftBaseWith cc = BitTorrent $ liftBaseWith $ \ cc' ->
@@ -114,6 +127,7 @@ instance MonadBaseControl IO BitTorrent where
114 127
115 restoreM = BitTorrent . restoreM . unSt 128 restoreM = BitTorrent . restoreM . unSt
116 {-# INLINE restoreM #-} 129 {-# INLINE restoreM #-}
130#endif
117 131
118-- | NOP. 132-- | NOP.
119instance MonadBitTorrent BitTorrent where 133instance MonadBitTorrent BitTorrent where
@@ -146,4 +160,4 @@ runBitTorrent client action = runReaderT (unBitTorrent action) client
146 160
147getClient :: BitTorrent Client 161getClient :: BitTorrent Client
148getClient = BitTorrent ask 162getClient = BitTorrent ask
149{-# INLINE getClient #-} \ No newline at end of file 163{-# INLINE getClient #-}