graphql-engine/server/src-lib/Hasura/Services/Network.hs
Tom Harding e0c0043e76 Upgrade Ormolu to 0.7.0.0
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9284
GitOrigin-RevId: 2f2cf2ad01900a54e4bdb970205ac0ef313c7e00
2023-05-24 13:53:53 +00:00

38 lines
1.3 KiB
Haskell

-- | Network service provider.
--
-- This module defines a Service (see Note [Services]) that provides access to
-- the network; for now, that only means providing a HTTP Manager. This is
-- consequentlt a simple analogue to `(MonadReader r m, Has Manager r)`, but
-- could be updated to either encompass other network utilities, or to provide a
-- more restricted interface if deemed useful. Alternatively this could be
-- removed altogether if all network calls were to be hidden behind more
-- specific services.
module Hasura.Services.Network
( ProvidesNetwork (..),
)
where
import Hasura.Prelude
import Hasura.Tracing
import Network.HTTP.Client qualified as HTTP
--------------------------------------------------------------------------------
class (Monad m) => ProvidesNetwork m where
askHTTPManager :: m HTTP.Manager
instance (ProvidesNetwork m) => ProvidesNetwork (ReaderT r m) where
askHTTPManager = lift askHTTPManager
instance (Monoid w, ProvidesNetwork m) => ProvidesNetwork (WriterT w m) where
askHTTPManager = lift askHTTPManager
instance (ProvidesNetwork m) => ProvidesNetwork (StateT s m) where
askHTTPManager = lift askHTTPManager
instance (ProvidesNetwork m) => ProvidesNetwork (ExceptT e m) where
askHTTPManager = lift askHTTPManager
instance (ProvidesNetwork m) => ProvidesNetwork (TraceT m) where
askHTTPManager = lift askHTTPManager