on master help sign in
Cleanup
575aa70Gaël Deest
servant-client-core/servant-client-core.cabal+1−1
@@ -52,7 +52,7 @@ library
52 build-depends:
52 build-depends:
53 base >= 4.9 && < 4.16
53 base >= 4.9 && < 4.16
54 , bytestring >= 0.10.8.1 && < 0.12
54 , bytestring >= 0.10.8.1 && < 0.12
55− , constraints
55+ , constraints >= 0.2 && < 0.14
56 , containers >= 0.5.7.1 && < 0.7
56 , containers >= 0.5.7.1 && < 0.7
57 , deepseq >= 1.4.2.0 && < 1.5
57 , deepseq >= 1.4.2.0 && < 1.5
58 , text >= 1.2.3.0 && < 1.3
58 , text >= 1.2.3.0 && < 1.3
servant-client-core/src/Servant/Client/Core/HasClient.hs+8−23
@@ -1,5 +1,4 @@
1{-# LANGUAGE ConstraintKinds #-}
1{-# LANGUAGE ConstraintKinds #-}
2−{-# LANGUAGE CPP #-}
3{-# LANGUAGE DataKinds #-}
2{-# LANGUAGE DataKinds #-}
4{-# LANGUAGE FlexibleContexts #-}
3{-# LANGUAGE FlexibleContexts #-}
5{-# LANGUAGE FlexibleInstances #-}
4{-# LANGUAGE FlexibleInstances #-}
@@ -7,6 +6,7 @@
7{-# LANGUAGE MultiParamTypeClasses #-}
6{-# LANGUAGE MultiParamTypeClasses #-}
8{-# LANGUAGE OverloadedStrings #-}
7{-# LANGUAGE OverloadedStrings #-}
9{-# LANGUAGE PolyKinds #-}
8{-# LANGUAGE PolyKinds #-}
9+{-# LANGUAGE QuantifiedConstraints #-}
10{-# LANGUAGE RankNTypes #-}
10{-# LANGUAGE RankNTypes #-}
11{-# LANGUAGE ScopedTypeVariables #-}
11{-# LANGUAGE ScopedTypeVariables #-}
12{-# LANGUAGE TypeApplications #-}
12{-# LANGUAGE TypeApplications #-}
@@ -14,14 +14,6 @@
14{-# LANGUAGE TypeOperators #-}
14{-# LANGUAGE TypeOperators #-}
15{-# LANGUAGE UndecidableInstances #-}
15{-# LANGUAGE UndecidableInstances #-}
16
16
17−#if MIN_VERSION_base(4,9,0) && __GLASGOW_HASKELL__ >= 802
18−#define HAS_TYPE_ERROR
19−#endif
20−
21−#if __GLASGOW_HASKELL__ >= 806
22−{-# LANGUAGE QuantifiedConstraints #-}
23−#endif
24−
25module Servant.Client.Core.HasClient (
17module Servant.Client.Core.HasClient (
26 clientIn,
18 clientIn,
27 HasClient (..),
19 HasClient (..),
@@ -804,11 +796,7 @@ instance ( HasClient m api
804-- > getBooks = client myApi
796-- > getBooks = client myApi
805-- > -- then you can just use "getBooksBy" to query that endpoint.
797-- > -- then you can just use "getBooksBy" to query that endpoint.
806-- > -- 'getBooks' for all books.
798-- > -- 'getBooks' for all books.
807−#ifdef HAS_TYPE_ERROR
808instance (AtLeastOneFragment api, FragmentUnique (Fragment a :> api), HasClient m api
799instance (AtLeastOneFragment api, FragmentUnique (Fragment a :> api), HasClient m api
809−#else
810−instance ( HasClient m api
811−#endif
812 ) => HasClient m (Fragment a :> api) where
800 ) => HasClient m (Fragment a :> api) where
813
801
814 type Client m (Fragment a :> api) = Client m api
802 type Client m (Fragment a :> api) = Client m api
@@ -833,7 +821,6 @@ data AsClientT (m :: * -> *)
833instance GenericMode (AsClientT m) where
821instance GenericMode (AsClientT m) where
834 type AsClientT m :- api = Client m api
822 type AsClientT m :- api = Client m api
835
823
836−#if __GLASGOW_HASKELL__ >= 806
837
824
838type GClientConstraints api m =
825type GClientConstraints api m =
839 ( GenericServant api (AsClientT m)
826 ( GenericServant api (AsClientT m)
@@ -873,8 +860,6 @@ instance
873 hoistClientMonad @m @(ToServantApi api) @ma @mb Proxy Proxy nat $
860 hoistClientMonad @m @(ToServantApi api) @ma @mb Proxy Proxy nat $
874 toServant @api @(AsClientT ma) clientA
861 toServant @api @(AsClientT ma) clientA
875
862
876−#endif
877−
878infixl 1 //
863infixl 1 //
879infixl 2 /:
864infixl 2 /:
880
865
@@ -885,14 +870,14 @@ infixl 2 /:
885-- Example:
870-- Example:
886--
871--
887-- @@
872-- @@
888−-- type Api = NamedAPI RootApi
873+-- type Api = NamedRoutes RootApi
889--
874--
890-- data RootApi mode = RootApi
875-- data RootApi mode = RootApi
891−-- { subApi :: mode :- NamedAPI SubApi
876+-- { subApi :: mode :- NamedRoutes SubApi
892-- , …
877-- , …
893-- } deriving Generic
878-- } deriving Generic
894--
879--
895−-- data SubAmi mode = SubApi
880+-- data SubApi mode = SubApi
896-- { endpoint :: mode :- Get '[JSON] Person
881-- { endpoint :: mode :- Get '[JSON] Person
897-- , …
882-- , …
898-- } deriving Generic
883-- } deriving Generic
@@ -912,20 +897,20 @@ x // f = f x
912-- | Convenience function for supplying arguments to client functions when
897-- | Convenience function for supplying arguments to client functions when
913-- working with records of clients.
898-- working with records of clients.
914--
899--
915−-- Intended to be use in conjunction with '(//)'.
900+-- Intended to be used in conjunction with '(//)'.
916--
901--
917-- Example:
902-- Example:
918--
903--
919-- @@
904-- @@
920−-- type Api = NamedAPI RootApi
905+-- type Api = NamedRoutes RootApi
921--
906--
922-- data RootApi mode = RootApi
907-- data RootApi mode = RootApi
923−-- { subApi :: mode :- Capture "token" String :> NamedAPI SubApi
908+-- { subApi :: mode :- Capture "token" String :> NamedRoutes SubApi
924-- , hello :: mode :- Capture "name" String :> Get '[JSON] String
909-- , hello :: mode :- Capture "name" String :> Get '[JSON] String
925-- , …
910-- , …
926-- } deriving Generic
911-- } deriving Generic
927--
912--
928−-- data SubAmi mode = SubApi
913+-- data SubApi mode = SubApi
929-- { endpoint :: mode :- Get '[JSON] Person
914-- { endpoint :: mode :- Get '[JSON] Person
930-- , …
915-- , …
931-- } deriving Generic
916-- } deriving Generic
servant-server/servant-server.cabal+1−1
@@ -62,7 +62,7 @@ library
62 build-depends:
62 build-depends:
63 base >= 4.9 && < 4.16
63 base >= 4.9 && < 4.16
64 , bytestring >= 0.10.8.1 && < 0.12
64 , bytestring >= 0.10.8.1 && < 0.12
65− , constraints
65+ , constraints >= 0.2 && < 0.14
66 , containers >= 0.5.7.1 && < 0.7
66 , containers >= 0.5.7.1 && < 0.7
67 , mtl >= 2.2.2 && < 2.3
67 , mtl >= 2.2.2 && < 2.3
68 , text >= 1.2.3.0 && < 1.3
68 , text >= 1.2.3.0 && < 1.3
servant-server/src/Servant/Server/Internal.hs+2−22
@@ -1,4 +1,3 @@
1−{-# LANGUAGE CPP #-}
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 #-}
19
19
20−#if MIN_VERSION_base(4,9,0) && __GLASGOW_HASKELL__ >= 802
21−#define HAS_TYPE_ERROR
22−#endif
23−
24−#if __GLASGOW_HASKELL__ >= 806
25−{-# LANGUAGE QuantifiedConstraints #-}
26−#endif
27−
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
113
105
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)
119−#endif
120
110
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
795
785
796ct_wildcard :: B.ByteString
786ct_wildcard :: B.ByteString
797−ct_wildcard = "*" <> "/" <> "*" -- Because CPP
787+ct_wildcard = "*" <> "/" <> "*"
798
788
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-------------------------------------------------------------------------------
827
817
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 ':>'.
831--
820--
@@ -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
891−#endif
892
880
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)
906−#else
907−instance (HasServer api context)
908−#endif
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
911
895
@@ -924,8 +908,6 @@ instance GenericMode (AsServerT m) where
924type AsServer = AsServerT Handler
908type AsServer = AsServerT Handler
925
909
926
910
927−#if __GLASGOW_HASKELL__ >= 806
928−
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
989−
990−#endif
servant/src/Servant/Links.hs+1−7
@@ -1,22 +1,18 @@
1{-# LANGUAGE AllowAmbiguousTypes #-}
1{-# LANGUAGE AllowAmbiguousTypes #-}
2{-# LANGUAGE ConstraintKinds #-}
2{-# LANGUAGE ConstraintKinds #-}
3−{-# LANGUAGE CPP #-}
4{-# LANGUAGE DataKinds #-}
3{-# LANGUAGE DataKinds #-}
5{-# LANGUAGE FlexibleContexts #-}
4{-# LANGUAGE FlexibleContexts #-}
6{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE FlexibleInstances #-}
7{-# LANGUAGE FunctionalDependencies #-}
6{-# LANGUAGE FunctionalDependencies #-}
8{-# LANGUAGE InstanceSigs #-}
7{-# LANGUAGE InstanceSigs #-}
9{-# LANGUAGE PolyKinds #-}
8{-# LANGUAGE PolyKinds #-}
9+{-# LANGUAGE QuantifiedConstraints #-}
10{-# LANGUAGE ScopedTypeVariables #-}
10{-# LANGUAGE ScopedTypeVariables #-}
11{-# LANGUAGE TypeApplications #-}
11{-# LANGUAGE TypeApplications #-}
12{-# LANGUAGE TypeFamilies #-}
12{-# LANGUAGE TypeFamilies #-}
13{-# LANGUAGE TypeOperators #-}
13{-# LANGUAGE TypeOperators #-}
14{-# LANGUAGE UndecidableInstances #-}
14{-# LANGUAGE UndecidableInstances #-}
15
15
16−#if __GLASGOW_HASKELL__ >= 806
17−{-# LANGUAGE QuantifiedConstraints #-}
18−#endif
19−
20{-# OPTIONS_HADDOCK not-home #-}
16{-# OPTIONS_HADDOCK not-home #-}
21
17
22-- | Type safe generation of internal links.
18-- | Type safe generation of internal links.
@@ -593,7 +589,6 @@ instance HasLink (UVerb m ct a) where
593 toLink toA _ = toA
589 toLink toA _ = toA
594-- Instance for NamedRoutes combinator
590-- Instance for NamedRoutes combinator
595
591
596−#if __GLASGOW_HASKELL__ >= 806
597type GLinkConstraints routes a =
592type GLinkConstraints routes a =
598 ( MkLink (ToServant routes AsApi) a ~ ToServant routes (AsLink a)
593 ( MkLink (ToServant routes AsApi) a ~ ToServant routes (AsLink a)
599 , GenericServant routes (AsLink a)
594 , GenericServant routes (AsLink a)
@@ -620,7 +615,6 @@ instance
620
615
621 toLink toA _ l = case proof @routes @a of
616 toLink toA _ l = case proof @routes @a of
622 Dict -> fromServant $ toLink toA (Proxy @(ToServantApi routes)) l
617 Dict -> fromServant $ toLink toA (Proxy @(ToServantApi routes)) l
623−#endif
624
618
625-- AuthProtext instances
619-- AuthProtext instances
626instance HasLink sub => HasLink (AuthProtect tag :> sub) where
620instance HasLink sub => HasLink (AuthProtect tag :> sub) where