{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Servant.Checked.Exceptions.Internal.Servant.Client where
import Data.Proxy (Proxy(Proxy))
import Servant.API (Verb, (:>), (:<|>))
import Servant.Client (HasClient(clientWithRoute, Client))
import Servant.Client.Core
import Servant.Checked.Exceptions.Internal.Envelope (Envelope)
import Servant.Checked.Exceptions.Internal.Servant.API
(NoThrow, Throws, Throwing, ThrowingNonterminal)
instance (RunClient m, HasClient m (Throwing '[e] :> api)) => HasClient m (Throws e :> api) where
type Client m (Throws e :> api) = Client m (Throwing '[e] :> api)
clientWithRoute
:: Proxy m
-> Proxy (Throws e :> api)
-> Request
-> Client m (Throwing '[e] :> api)
clientWithRoute :: Proxy m
-> Proxy (Throws e :> api)
-> Request
-> Client m (Throwing '[e] :> api)
clientWithRoute Proxy m
p Proxy (Throws e :> api)
Proxy = Proxy m
-> Proxy (Throwing '[e] :> api)
-> Request
-> Client m (Throwing '[e] :> api)
forall (m :: * -> *) api.
HasClient m api =>
Proxy m -> Proxy api -> Request -> Client m api
clientWithRoute Proxy m
p (Proxy (Throwing '[e] :> api)
forall k (t :: k). Proxy t
Proxy @(Throwing '[e] :> api))
hoistClientMonad
:: Proxy m
-> Proxy (Throws e :> api)
-> (forall x. mon x -> mon' x)
-> Client mon (Throws e :> api)
-> Client mon' (Throwing '[e] :> api)
hoistClientMonad :: Proxy m
-> Proxy (Throws e :> api)
-> (forall x. mon x -> mon' x)
-> Client mon (Throws e :> api)
-> Client mon' (Throwing '[e] :> api)
hoistClientMonad Proxy m
pm Proxy (Throws e :> api)
_ = Proxy m
-> Proxy (Throwing '[e] :> api)
-> (forall x. mon x -> mon' x)
-> Client mon (Throwing '[e] :> api)
-> Client mon' (Throwing '[e] :> api)
forall (m :: * -> *) api (mon :: * -> *) (mon' :: * -> *).
HasClient m api =>
Proxy m
-> Proxy api
-> (forall x. mon x -> mon' x)
-> Client mon api
-> Client mon' api
hoistClientMonad Proxy m
pm (Proxy (Throwing '[e] :> api)
forall k (t :: k). Proxy t
Proxy @(Throwing '[e] :> api))
instance (HasClient m (Verb method status ctypes (Envelope es a))) =>
HasClient m (Throwing es :> Verb method status ctypes a) where
type Client m (Throwing es :> Verb method status ctypes a) =
Client m (Verb method status ctypes (Envelope es a))
clientWithRoute
:: Proxy m
-> Proxy (Throwing es :> Verb method status ctypes a)
-> Request
-> Client m (Verb method status ctypes (Envelope es a))
clientWithRoute :: Proxy m
-> Proxy (Throwing es :> Verb method status ctypes a)
-> Request
-> Client m (Verb method status ctypes (Envelope es a))
clientWithRoute Proxy m
p Proxy (Throwing es :> Verb method status ctypes a)
Proxy =
Proxy m
-> Proxy (Verb method status ctypes (Envelope es a))
-> Request
-> Client m (Verb method status ctypes (Envelope es a))
forall (m :: * -> *) api.
HasClient m api =>
Proxy m -> Proxy api -> Request -> Client m api
clientWithRoute Proxy m
p (Proxy (Verb method status ctypes (Envelope es a))
forall k (t :: k). Proxy t
Proxy :: Proxy (Verb method status ctypes (Envelope es a)))
hoistClientMonad
:: Proxy m
-> Proxy (Throwing es :> Verb method status ctypes a)
-> (forall x. mon x -> mon' x)
-> Client mon (Throwing es :> Verb method status ctypes a)
-> Client mon' (Verb method status ctypes (Envelope es a))
hoistClientMonad :: Proxy m
-> Proxy (Throwing es :> Verb method status ctypes a)
-> (forall x. mon x -> mon' x)
-> Client mon (Throwing es :> Verb method status ctypes a)
-> Client mon' (Verb method status ctypes (Envelope es a))
hoistClientMonad Proxy m
pm Proxy (Throwing es :> Verb method status ctypes a)
_ =
Proxy m
-> Proxy (Verb method status ctypes (Envelope es a))
-> (forall x. mon x -> mon' x)
-> Client mon (Verb method status ctypes (Envelope es a))
-> Client mon' (Verb method status ctypes (Envelope es a))
forall (m :: * -> *) api (mon :: * -> *) (mon' :: * -> *).
HasClient m api =>
Proxy m
-> Proxy api
-> (forall x. mon x -> mon' x)
-> Client mon api
-> Client mon' api
hoistClientMonad Proxy m
pm (Proxy (Verb method status ctypes (Envelope es a))
forall k (t :: k). Proxy t
Proxy @(Verb method status ctypes (Envelope es a)))
instance (RunClient m, HasClient m (Verb method status ctypes (Envelope '[] a))) =>
HasClient m (NoThrow :> Verb method status ctypes a) where
type Client m (NoThrow :> Verb method status ctypes a) =
Client m (Verb method status ctypes (Envelope '[] a))
clientWithRoute
:: Proxy m
-> Proxy (NoThrow :> Verb method status ctypes a)
-> Request
-> Client m (Verb method status ctypes (Envelope '[] a))
clientWithRoute :: Proxy m
-> Proxy (NoThrow :> Verb method status ctypes a)
-> Request
-> Client m (Verb method status ctypes (Envelope '[] a))
clientWithRoute Proxy m
p Proxy (NoThrow :> Verb method status ctypes a)
Proxy =
Proxy m
-> Proxy (Verb method status ctypes (Envelope '[] a))
-> Request
-> Client m (Verb method status ctypes (Envelope '[] a))
forall (m :: * -> *) api.
HasClient m api =>
Proxy m -> Proxy api -> Request -> Client m api
clientWithRoute Proxy m
p (Proxy (Verb method status ctypes (Envelope '[] a))
forall k (t :: k). Proxy t
Proxy :: Proxy (Verb method status ctypes (Envelope '[] a)))
hoistClientMonad
:: Proxy m
-> Proxy (NoThrow :> Verb method status ctypes a)
-> (forall x. mon x -> mon' x)
-> Client mon (NoThrow :> Verb method status ctypes a)
-> Client mon' (Verb method status ctypes (Envelope '[] a))
hoistClientMonad :: Proxy m
-> Proxy (NoThrow :> Verb method status ctypes a)
-> (forall x. mon x -> mon' x)
-> Client mon (NoThrow :> Verb method status ctypes a)
-> Client mon' (Verb method status ctypes (Envelope '[] a))
hoistClientMonad Proxy m
pm Proxy (NoThrow :> Verb method status ctypes a)
_ =
Proxy m
-> Proxy (Verb method status ctypes (Envelope '[] a))
-> (forall x. mon x -> mon' x)
-> Client mon (Verb method status ctypes (Envelope '[] a))
-> Client mon' (Verb method status ctypes (Envelope '[] a))
forall (m :: * -> *) api (mon :: * -> *) (mon' :: * -> *).
HasClient m api =>
Proxy m
-> Proxy api
-> (forall x. mon x -> mon' x)
-> Client mon api
-> Client mon' api
hoistClientMonad Proxy m
pm (Proxy (Verb method status ctypes (Envelope '[] a))
forall k (t :: k). Proxy t
Proxy @(Verb method status ctypes (Envelope '[] a)))
instance (RunClient m, HasClient m ((Throwing es :> api1) :<|> (Throwing es :> api2))) =>
HasClient m (Throwing es :> (api1 :<|> api2)) where
type Client m (Throwing es :> (api1 :<|> api2)) =
Client m ((Throwing es :> api1) :<|> (Throwing es :> api2))
clientWithRoute
:: Proxy m
-> Proxy (Throwing es :> (api1 :<|> api2))
-> Request
-> Client m ((Throwing es :> api1) :<|> (Throwing es :> api2))
clientWithRoute :: Proxy m
-> Proxy (Throwing es :> (api1 :<|> api2))
-> Request
-> Client m ((Throwing es :> api1) :<|> (Throwing es :> api2))
clientWithRoute Proxy m
p Proxy (Throwing es :> (api1 :<|> api2))
_ =
Proxy m
-> Proxy ((Throwing es :> api1) :<|> (Throwing es :> api2))
-> Request
-> Client m ((Throwing es :> api1) :<|> (Throwing es :> api2))
forall (m :: * -> *) api.
HasClient m api =>
Proxy m -> Proxy api -> Request -> Client m api
clientWithRoute Proxy m
p (Proxy ((Throwing es :> api1) :<|> (Throwing es :> api2))
forall k (t :: k). Proxy t
Proxy :: Proxy ((Throwing es :> api1) :<|> (Throwing es :> api2)))
hoistClientMonad
:: Proxy m
-> Proxy (Throwing es :> (api1 :<|> api2))
-> (forall x. mon x -> mon' x)
-> Client mon (Throwing es :> (api1 :<|> api2))
-> Client mon' ((Throwing es :> api1) :<|> (Throwing es :> api2))
hoistClientMonad :: Proxy m
-> Proxy (Throwing es :> (api1 :<|> api2))
-> (forall x. mon x -> mon' x)
-> Client mon (Throwing es :> (api1 :<|> api2))
-> Client mon' ((Throwing es :> api1) :<|> (Throwing es :> api2))
hoistClientMonad Proxy m
pm Proxy (Throwing es :> (api1 :<|> api2))
_ =
Proxy m
-> Proxy (Throwing es :> (api1 :<|> api2))
-> (forall x. mon x -> mon' x)
-> Client mon (Throwing es :> (api1 :<|> api2))
-> Client mon' (Throwing es :> (api1 :<|> api2))
forall (m :: * -> *) api (mon :: * -> *) (mon' :: * -> *).
HasClient m api =>
Proxy m
-> Proxy api
-> (forall x. mon x -> mon' x)
-> Client mon api
-> Client mon' api
hoistClientMonad Proxy m
pm (Proxy (Throwing es :> (api1 :<|> api2))
forall k (t :: k). Proxy t
Proxy @(Throwing es :> (api1 :<|> api2)))
instance (RunClient m, HasClient m ((NoThrow :> api1) :<|> (NoThrow :> api2))) =>
HasClient m (NoThrow :> (api1 :<|> api2)) where
type Client m (NoThrow :> (api1 :<|> api2)) =
Client m ((NoThrow :> api1) :<|> (NoThrow :> api2))
clientWithRoute
:: Proxy m
-> Proxy (NoThrow :> (api1 :<|> api2))
-> Request
-> Client m ((NoThrow :> api1) :<|> (NoThrow :> api2))
clientWithRoute :: Proxy m
-> Proxy (NoThrow :> (api1 :<|> api2))
-> Request
-> Client m ((NoThrow :> api1) :<|> (NoThrow :> api2))
clientWithRoute Proxy m
p Proxy (NoThrow :> (api1 :<|> api2))
_ =
Proxy m
-> Proxy ((NoThrow :> api1) :<|> (NoThrow :> api2))
-> Request
-> Client m ((NoThrow :> api1) :<|> (NoThrow :> api2))
forall (m :: * -> *) api.
HasClient m api =>
Proxy m -> Proxy api -> Request -> Client m api
clientWithRoute Proxy m
p (Proxy ((NoThrow :> api1) :<|> (NoThrow :> api2))
forall k (t :: k). Proxy t
Proxy :: Proxy ((NoThrow :> api1) :<|> (NoThrow :> api2)))
hoistClientMonad
:: Proxy m
-> Proxy (NoThrow :> (api1 :<|> api2))
-> (forall x. mon x -> mon' x)
-> Client mon (NoThrow :> (api1 :<|> api2))
-> Client mon' ((NoThrow :> api1) :<|> (NoThrow :> api2))
hoistClientMonad :: Proxy m
-> Proxy (NoThrow :> (api1 :<|> api2))
-> (forall x. mon x -> mon' x)
-> Client mon (NoThrow :> (api1 :<|> api2))
-> Client mon' ((NoThrow :> api1) :<|> (NoThrow :> api2))
hoistClientMonad Proxy m
pm Proxy (NoThrow :> (api1 :<|> api2))
_ =
Proxy m
-> Proxy (NoThrow :> (api1 :<|> api2))
-> (forall x. mon x -> mon' x)
-> Client mon (NoThrow :> (api1 :<|> api2))
-> Client mon' (NoThrow :> (api1 :<|> api2))
forall (m :: * -> *) api (mon :: * -> *) (mon' :: * -> *).
HasClient m api =>
Proxy m
-> Proxy api
-> (forall x. mon x -> mon' x)
-> Client mon api
-> Client mon' api
hoistClientMonad Proxy m
pm (Proxy (NoThrow :> (api1 :<|> api2))
forall k (t :: k). Proxy t
Proxy @(NoThrow :> (api1 :<|> api2)))
instance (RunClient m, HasClient m (ThrowingNonterminal (Throwing es :> api :> apis))) =>
HasClient m (Throwing es :> api :> apis) where
type Client m (Throwing es :> api :> apis) =
Client m (ThrowingNonterminal (Throwing es :> api :> apis))
clientWithRoute
:: Proxy m
-> Proxy (Throwing es :> api :> apis)
-> Request
-> Client m (ThrowingNonterminal (Throwing es :> api :> apis))
clientWithRoute :: Proxy m
-> Proxy (Throwing es :> (api :> apis))
-> Request
-> Client m (ThrowingNonterminal (Throwing es :> (api :> apis)))
clientWithRoute Proxy m
p Proxy (Throwing es :> (api :> apis))
_ =
Proxy m
-> Proxy (ThrowingNonterminal (Throwing es :> (api :> apis)))
-> Request
-> Client m (ThrowingNonterminal (Throwing es :> (api :> apis)))
forall (m :: * -> *) api.
HasClient m api =>
Proxy m -> Proxy api -> Request -> Client m api
clientWithRoute Proxy m
p (Proxy (ThrowingNonterminal (Throwing es :> (api :> apis)))
forall k (t :: k). Proxy t
Proxy :: Proxy (ThrowingNonterminal (Throwing es :> api :> apis)))
hoistClientMonad
:: Proxy m
-> Proxy (Throwing es :> api :> apis)
-> (forall x. mon x -> mon' x)
-> Client mon (Throwing es :> api :> apis)
-> Client mon' (ThrowingNonterminal (Throwing es :> api :> apis))
hoistClientMonad :: Proxy m
-> Proxy (Throwing es :> (api :> apis))
-> (forall x. mon x -> mon' x)
-> Client mon (Throwing es :> (api :> apis))
-> Client mon' (ThrowingNonterminal (Throwing es :> (api :> apis)))
hoistClientMonad Proxy m
pm Proxy (Throwing es :> (api :> apis))
_ =
Proxy m
-> Proxy (ThrowingNonterminal (Throwing es :> (api :> apis)))
-> (forall x. mon x -> mon' x)
-> Client mon (ThrowingNonterminal (Throwing es :> (api :> apis)))
-> Client mon' (ThrowingNonterminal (Throwing es :> (api :> apis)))
forall (m :: * -> *) api (mon :: * -> *) (mon' :: * -> *).
HasClient m api =>
Proxy m
-> Proxy api
-> (forall x. mon x -> mon' x)
-> Client mon api
-> Client mon' api
hoistClientMonad Proxy m
pm (Proxy (ThrowingNonterminal (Throwing es :> (api :> apis)))
forall k (t :: k). Proxy t
Proxy @(ThrowingNonterminal (Throwing es :> api :> apis)))
instance (RunClient m, HasClient m (api :> NoThrow :> apis)) =>
HasClient m (NoThrow :> api :> apis) where
type Client m (NoThrow :> api :> apis) =
Client m (api :> NoThrow :> apis)
clientWithRoute
:: Proxy m
-> Proxy (NoThrow :> api :> apis)
-> Request
-> Client m (api :> NoThrow :> apis)
clientWithRoute :: Proxy m
-> Proxy (NoThrow :> (api :> apis))
-> Request
-> Client m (api :> (NoThrow :> apis))
clientWithRoute Proxy m
p Proxy (NoThrow :> (api :> apis))
_ =
Proxy m
-> Proxy (api :> (NoThrow :> apis))
-> Request
-> Client m (api :> (NoThrow :> apis))
forall (m :: * -> *) api.
HasClient m api =>
Proxy m -> Proxy api -> Request -> Client m api
clientWithRoute Proxy m
p (Proxy (api :> (NoThrow :> apis))
forall k (t :: k). Proxy t
Proxy :: Proxy (api :> NoThrow :> apis))
hoistClientMonad
:: Proxy m
-> Proxy (NoThrow :> api :> apis)
-> (forall x. mon x -> mon' x)
-> Client mon (NoThrow :> api :> apis)
-> Client mon' (api :> NoThrow :> apis)
hoistClientMonad :: Proxy m
-> Proxy (NoThrow :> (api :> apis))
-> (forall x. mon x -> mon' x)
-> Client mon (NoThrow :> (api :> apis))
-> Client mon' (api :> (NoThrow :> apis))
hoistClientMonad Proxy m
pm Proxy (NoThrow :> (api :> apis))
_ =
Proxy m
-> Proxy (api :> (NoThrow :> apis))
-> (forall x. mon x -> mon' x)
-> Client mon (api :> (NoThrow :> apis))
-> Client mon' (api :> (NoThrow :> apis))
forall (m :: * -> *) api (mon :: * -> *) (mon' :: * -> *).
HasClient m api =>
Proxy m
-> Proxy api
-> (forall x. mon x -> mon' x)
-> Client mon api
-> Client mon' api
hoistClientMonad Proxy m
pm (Proxy (api :> (NoThrow :> apis))
forall k (t :: k). Proxy t
Proxy @(api :> NoThrow :> apis))