module Network.HTTP.Client.Manager
  ( HasHttpManagerM (..),
    HTTP.Manager,
  )
where

import Control.Monad.Except
import Control.Monad.Reader
import Control.Monad.State.Strict
import Control.Monad.Writer.Strict
import Network.HTTP.Client as HTTP

class (Monad m) => HasHttpManagerM m where
  askHttpManager :: m HTTP.Manager

instance (HasHttpManagerM m) => HasHttpManagerM (ExceptT e m) where
  askHttpManager :: ExceptT e m Manager
askHttpManager = m Manager -> ExceptT e m Manager
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m Manager
forall (m :: * -> *). HasHttpManagerM m => m Manager
askHttpManager

instance (HasHttpManagerM m) => HasHttpManagerM (ReaderT r m) where
  askHttpManager :: ReaderT r m Manager
askHttpManager = m Manager -> ReaderT r m Manager
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m Manager
forall (m :: * -> *). HasHttpManagerM m => m Manager
askHttpManager

instance (HasHttpManagerM m) => HasHttpManagerM (StateT s m) where
  askHttpManager :: StateT s m Manager
askHttpManager = m Manager -> StateT s m Manager
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m Manager
forall (m :: * -> *). HasHttpManagerM m => m Manager
askHttpManager

instance (Monoid w, HasHttpManagerM m) => HasHttpManagerM (WriterT w m) where
  askHttpManager :: WriterT w m Manager
askHttpManager = m Manager -> WriterT w m Manager
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m Manager
forall (m :: * -> *). HasHttpManagerM m => m Manager
askHttpManager