From a930544ab2326b58bd088667d4d8f4a0c0dc884d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Deest?= Date: Sat, 2 Oct 2021 17:32:41 +0200 Subject: [PATCH] Exclude quantified constraints code for GHCJS QuantifiedConstraints isn't available for GHC 8.4 (where our GHCJS version is still stuck). We may need to take a drastic decision for GHCJS at some point. --- servant-client-core/src/Servant/Client/Generic.hs | 11 ++++++++++- servant-server/src/Servant/Server/Generic.hs | 10 ++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/servant-client-core/src/Servant/Client/Generic.hs b/servant-client-core/src/Servant/Client/Generic.hs index aee599d4..8452df42 100644 --- a/servant-client-core/src/Servant/Client/Generic.hs +++ b/servant-client-core/src/Servant/Client/Generic.hs @@ -1,16 +1,21 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE InstanceSigs #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE QuantifiedConstraints #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} + +#if __GLASGOW_HASKELL__ >= 806 +{-# LANGUAGE QuantifiedConstraints #-} +#endif + module Servant.Client.Generic ( AsClientT, genericClient, @@ -58,6 +63,8 @@ genericClientHoist nt m = Proxy :: Proxy m api = Proxy :: Proxy (ToServantApi routes) +#if __GLASGOW_HASKELL__ >= 806 + type GClientConstraints api m = ( GenericServant api (AsClientT m) , Client m (ToServantApi api) ~ ToServant api (AsClientT m) @@ -95,3 +102,5 @@ instance fromServant @api @(AsClientT mb) $ hoistClientMonad @m @(ToServantApi api) @ma @mb Proxy Proxy nat $ toServant @api @(AsClientT ma) clientA + +#endif diff --git a/servant-server/src/Servant/Server/Generic.hs b/servant-server/src/Servant/Server/Generic.hs index c4a6f934..65343ed3 100644 --- a/servant-server/src/Servant/Server/Generic.hs +++ b/servant-server/src/Servant/Server/Generic.hs @@ -1,6 +1,7 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE FlexibleContexts #-} @@ -15,6 +16,11 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} + +#if __GLASGOW_HASKELL__ >= 806 +{-# LANGUAGE QuantifiedConstraints #-} +#endif + -- | @since 0.14.1 module Servant.Server.Generic ( AsServerT, @@ -113,6 +119,8 @@ genericServerT -> ToServant routes (AsServerT m) genericServerT = toServant +#if __GLASGOW_HASKELL__ >= 806 + -- | Set of constraints required to convert to / from vanilla server types. type GServerConstraints api m = ( ToServant api (AsServerT m) ~ ServerT (ToServantApi api) m @@ -173,3 +181,5 @@ instance toServant server servantSrvN :: ServerT (ToServantApi api) n = hoistServerWithContext (Proxy @(ToServantApi api)) pctx nat servantSrvM + +#endif