@@ -1,4 +1,3 @@
2{-# LANGUAGE AllowAmbiguousTypes #-}
1{-# LANGUAGE AllowAmbiguousTypes #-}
3{-# LANGUAGE ConstraintKinds #-}
2{-# LANGUAGE ConstraintKinds #-}
4{-# LANGUAGE DataKinds #-}
3{-# LANGUAGE DataKinds #-}
@@ -9,6 +8,7 @@
9{-# LANGUAGE MultiParamTypeClasses #-}
8{-# LANGUAGE MultiParamTypeClasses #-}
10{-# LANGUAGE OverloadedStrings #-}
9{-# LANGUAGE OverloadedStrings #-}
11{-# LANGUAGE PolyKinds #-}
10{-# LANGUAGE PolyKinds #-}
11+{-# LANGUAGE QuantifiedConstraints #-}
12{-# LANGUAGE RankNTypes #-}
12{-# LANGUAGE RankNTypes #-}
13{-# LANGUAGE ScopedTypeVariables #-}
13{-# LANGUAGE ScopedTypeVariables #-}
14{-# LANGUAGE TupleSections #-}
14{-# LANGUAGE TupleSections #-}
@@ -17,14 +17,6 @@
17{-# LANGUAGE TypeOperators #-}
17{-# LANGUAGE TypeOperators #-}
18{-# LANGUAGE UndecidableInstances #-}
18{-# LANGUAGE UndecidableInstances #-}
20−#if MIN_VERSION_base(4,9,0) && __GLASGOW_HASKELL__ >= 802
21−#define HAS_TYPE_ERROR
24−#if __GLASGOW_HASKELL__ >= 806
25−{-# LANGUAGE QuantifiedConstraints #-}
28module Servant.Server.Internal
20module Servant.Server.Internal
29 ( module Servant.Server.Internal
21 ( module Servant.Server.Internal
30 , module Servant.Server.Internal.BasicAuth
22 , module Servant.Server.Internal.BasicAuth
@@ -111,12 +103,10 @@ import Servant.Server.Internal.RouteResult
111import Servant.Server.Internal.RoutingApplication
103import Servant.Server.Internal.RoutingApplication
112import Servant.Server.Internal.ServerError
104import Servant.Server.Internal.ServerError
114−#ifdef HAS_TYPE_ERROR
115import GHC.TypeLits
106import GHC.TypeLits
116 (ErrorMessage (..), TypeError)
107 (ErrorMessage (..), TypeError)
117import Servant.API.TypeLevel
108import Servant.API.TypeLevel
118 (AtLeastOneFragment, FragmentUnique)
109 (AtLeastOneFragment, FragmentUnique)
121class HasServer api context where
111class HasServer api context where
122 type ServerT api (m :: * -> *) :: *
112 type ServerT api (m :: * -> *) :: *
@@ -794,7 +784,7 @@ instance ( KnownSymbol realm
794-- * helpers
784-- * helpers
796ct_wildcard :: B.ByteString
786ct_wildcard :: B.ByteString
797−ct_wildcard = "*" <> "/" <> "*" -- Because CPP
787+ct_wildcard = "*" <> "/" <> "*"
799getAcceptHeader :: Request -> AcceptHeader
789getAcceptHeader :: Request -> AcceptHeader
800getAcceptHeader = AcceptHeader . fromMaybe ct_wildcard . lookup hAccept . requestHeaders
790getAcceptHeader = AcceptHeader . fromMaybe ct_wildcard . lookup hAccept . requestHeaders
@@ -825,7 +815,6 @@ instance (HasContextEntry context (NamedContext name subContext), HasServer subA
825-- TypeError helpers
815-- TypeError helpers
826-------------------------------------------------------------------------------
816-------------------------------------------------------------------------------
828−#ifdef HAS_TYPE_ERROR
829-- | This instance catches mistakes when there are non-saturated
818-- | This instance catches mistakes when there are non-saturated
830-- type applications on LHS of ':>'.
819-- type applications on LHS of ':>'.
@@ -888,7 +877,6 @@ type HasServerArrowTypeError a b =
888 ':$$: 'ShowType a
877 ':$$: 'ShowType a
889 ':$$: 'Text "and"
878 ':$$: 'Text "and"
890 ':$$: 'ShowType b
879 ':$$: 'ShowType b
893-- | Ignore @'Fragment'@ in server handlers.
881-- | Ignore @'Fragment'@ in server handlers.
894-- See <https://ietf.org/rfc/rfc2616.html#section-15.1.3> for more details.
882-- See <https://ietf.org/rfc/rfc2616.html#section-15.1.3> for more details.
@@ -901,11 +889,7 @@ type HasServerArrowTypeError a b =
901-- > server = getBooks
889-- > server = getBooks
902-- > where getBooks :: Handler [Book]
890-- > where getBooks :: Handler [Book]
903-- > getBooks = ...return all books...
891-- > getBooks = ...return all books...
904−#ifdef HAS_TYPE_ERROR
905instance (AtLeastOneFragment api, FragmentUnique (Fragment a1 :> api), HasServer api context)
892instance (AtLeastOneFragment api, FragmentUnique (Fragment a1 :> api), HasServer api context)
907−instance (HasServer api context)
909 => HasServer (Fragment a1 :> api) context where
893 => HasServer (Fragment a1 :> api) context where
910 type ServerT (Fragment a1 :> api) m = ServerT api m
894 type ServerT (Fragment a1 :> api) m = ServerT api m
@@ -924,8 +908,6 @@ instance GenericMode (AsServerT m) where
924type AsServer = AsServerT Handler
908type AsServer = AsServerT Handler
927−#if __GLASGOW_HASKELL__ >= 806
929-- | Set of constraints required to convert to / from vanilla server types.
911-- | Set of constraints required to convert to / from vanilla server types.
930type GServerConstraints api m =
912type GServerConstraints api m =
931 ( ToServant api (AsServerT m) ~ ServerT (ToServantApi api) m
913 ( ToServant api (AsServerT m) ~ ServerT (ToServantApi api) m
@@ -986,5 +968,3 @@ instance
986 toServant server
968 toServant server
987 servantSrvN :: ServerT (ToServantApi api) n =
969 servantSrvN :: ServerT (ToServantApi api) n =
988 hoistServerWithContext (Proxy @(ToServantApi api)) pctx nat servantSrvM
970 hoistServerWithContext (Proxy @(ToServantApi api)) pctx nat servantSrvM