{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Servant.RawM.Internal.Client where
import Data.Proxy (Proxy(Proxy))
import Servant.Client (Client, HasClient(clientWithRoute, hoistClientMonad))
import Servant.Client.Core (runRequest, RunClient, Request, Response)
import Servant.RawM.Internal.API (RawM')
instance RunClient m => HasClient m (RawM' serverType) where
type Client m (RawM' serverType) = (Request -> Request) -> m Response
clientWithRoute
:: Proxy m
-> Proxy (RawM' serverType)
-> Request
-> Client m (RawM' serverType)
clientWithRoute Proxy Proxy req reqFunc = runRequest $ reqFunc req
hoistClientMonad
:: Proxy m
-> Proxy (RawM' serverType)
-> (forall x. mon x -> mon' x)
-> Client mon (RawM' serverType)
-> Client mon' (RawM' serverType)
hoistClientMonad Proxy Proxy f cl = \meth -> f (cl meth)