{-# options_haddock prune #-}
module Polysemy.Http.Interpreter.Manager where
import Network.HTTP.Client (newManager)
import qualified Network.HTTP.Client as HTTP (Manager)
import Network.HTTP.Client.TLS (mkManagerSettings)
import Polysemy.Http.Effect.Manager (Manager (..))
interpretManagerWith ::
HTTP.Manager ->
InterpreterFor Manager r
interpretManagerWith :: Manager -> InterpreterFor Manager r
interpretManagerWith Manager
manager = do
(forall (rInitial :: EffectRow) x.
Manager (Sem rInitial) x -> Sem r x)
-> Sem (Manager : r) a -> Sem r a
forall (e :: Effect) (r :: EffectRow) a.
FirstOrder e "interpret" =>
(forall (rInitial :: EffectRow) x. e (Sem rInitial) x -> Sem r x)
-> Sem (e : r) a -> Sem r a
interpret \ Manager (Sem rInitial) x
Get -> Manager -> Sem r Manager
forall (f :: * -> *) a. Applicative f => a -> f a
pure Manager
manager
{-# inline interpretManagerWith #-}
interpretManager ::
Member (Embed IO) r =>
InterpreterFor Manager r
interpretManager :: InterpreterFor Manager r
interpretManager Sem (Manager : r) a
sem = do
Manager
manager <- IO Manager -> Sem r Manager
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (ManagerSettings -> IO Manager
newManager ManagerSettings
settings)
Manager -> Sem (Manager : r) a -> Sem r a
forall (r :: EffectRow). Manager -> InterpreterFor Manager r
interpretManagerWith Manager
manager Sem (Manager : r) a
sem
where
settings :: ManagerSettings
settings =
TLSSettings -> Maybe SockSettings -> ManagerSettings
mkManagerSettings TLSSettings
forall a. Default a => a
def Maybe SockSettings
forall a. Maybe a
Nothing
{-# inline interpretManager #-}