git.iko.soy/typeable/servant
on master help sign in
Cleanup
commit575aa70ecad2a725a726178ed352b77f4238e0ca authorGaël Deest <gael.deest@tweag.io> dateMon 4 Oct 2021, 23:21 (5 years ago) parentd81c8d9
5 files changed+13−54
servant-client-core/servant-client-core.cabal+1−1 servant-client-core/src/Servant/Client/Core/HasClient.hs+8−23 servant-server/servant-server.cabal+1−1 servant-server/src/Servant/Server/Internal.hs+2−22 servant/src/Servant/Links.hs+1−7
servant-client-core/servant-client-core.cabal+1−1
@@ -52,7 +52,7 @@ library
5252 build-depends:
5353 base >= 4.9 && < 4.16
5454 , bytestring >= 0.10.8.1 && < 0.12
55− , constraints
55+ , constraints >= 0.2 && < 0.14
5656 , containers >= 0.5.7.1 && < 0.7
5757 , deepseq >= 1.4.2.0 && < 1.5
5858 , text >= 1.2.3.0 && < 1.3
servant-client-core/src/Servant/Client/Core/HasClient.hs+8−23
@@ -1,5 +1,4 @@
11{-# LANGUAGE ConstraintKinds #-}
2−{-# LANGUAGE CPP #-}
32{-# LANGUAGE DataKinds #-}
43{-# LANGUAGE FlexibleContexts #-}
54{-# LANGUAGE FlexibleInstances #-}
@@ -7,6 +6,7 @@
76{-# LANGUAGE MultiParamTypeClasses #-}
87{-# LANGUAGE OverloadedStrings #-}
98{-# LANGUAGE PolyKinds #-}
9+{-# LANGUAGE QuantifiedConstraints #-}
1010{-# LANGUAGE RankNTypes #-}
1111{-# LANGUAGE ScopedTypeVariables #-}
1212{-# LANGUAGE TypeApplications #-}
@@ -14,14 +14,6 @@
1414{-# LANGUAGE TypeOperators #-}
1515{-# LANGUAGE UndecidableInstances #-}
1616
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−
2517module Servant.Client.Core.HasClient (
2618 clientIn,
2719 HasClient (..),
@@ -804,11 +796,7 @@ instance ( HasClient m api
804796-- > getBooks = client myApi
805797-- > -- then you can just use "getBooksBy" to query that endpoint.
806798-- > -- 'getBooks' for all books.
807−#ifdef HAS_TYPE_ERROR
808799instance (AtLeastOneFragment api, FragmentUnique (Fragment a :> api), HasClient m api
809−#else
810−instance ( HasClient m api
811−#endif
812800 ) => HasClient m (Fragment a :> api) where
813801
814802 type Client m (Fragment a :> api) = Client m api
@@ -833,7 +821,6 @@ data AsClientT (m :: * -> *)
833821instance GenericMode (AsClientT m) where
834822 type AsClientT m :- api = Client m api
835823
836−#if __GLASGOW_HASKELL__ >= 806
837824
838825type GClientConstraints api m =
839826 ( GenericServant api (AsClientT m)
@@ -873,8 +860,6 @@ instance
873860 hoistClientMonad @m @(ToServantApi api) @ma @mb Proxy Proxy nat $
874861 toServant @api @(AsClientT ma) clientA
875862
876−#endif
877−
878863infixl 1 //
879864infixl 2 /:
880865
@@ -885,14 +870,14 @@ infixl 2 /:
885870-- Example:
886871--
887872-- @@
888−-- type Api = NamedAPI RootApi
873+-- type Api = NamedRoutes RootApi
889874--
890875-- data RootApi mode = RootApi
891−-- { subApi :: mode :- NamedAPI SubApi
876+-- { subApi :: mode :- NamedRoutes SubApi
892877-- , …
893878-- } deriving Generic
894879--
895−-- data SubAmi mode = SubApi
880+-- data SubApi mode = SubApi
896881-- { endpoint :: mode :- Get '[JSON] Person
897882-- , …
898883-- } deriving Generic
@@ -912,20 +897,20 @@ x // f = f x
912897-- | Convenience function for supplying arguments to client functions when
913898-- working with records of clients.
914899--
915−-- Intended to be use in conjunction with '(//)'.
900+-- Intended to be used in conjunction with '(//)'.
916901--
917902-- Example:
918903--
919904-- @@
920−-- type Api = NamedAPI RootApi
905+-- type Api = NamedRoutes RootApi
921906--
922907-- data RootApi mode = RootApi
923−-- { subApi :: mode :- Capture "token" String :> NamedAPI SubApi
908+-- { subApi :: mode :- Capture "token" String :> NamedRoutes SubApi
924909-- , hello :: mode :- Capture "name" String :> Get '[JSON] String
925910-- , …
926911-- } deriving Generic
927912--
928−-- data SubAmi mode = SubApi
913+-- data SubApi mode = SubApi
929914-- { endpoint :: mode :- Get '[JSON] Person
930915-- , …
931916-- } deriving Generic
servant-server/servant-server.cabal+1−1
@@ -62,7 +62,7 @@ library
6262 build-depends:
6363 base >= 4.9 && < 4.16
6464 , bytestring >= 0.10.8.1 && < 0.12
65− , constraints
65+ , constraints >= 0.2 && < 0.14
6666 , containers >= 0.5.7.1 && < 0.7
6767 , mtl >= 2.2.2 && < 2.3
6868 , text >= 1.2.3.0 && < 1.3
servant-server/src/Servant/Server/Internal.hs+2−22
@@ -1,4 +1,3 @@
1−{-# LANGUAGE CPP #-}
21{-# LANGUAGE AllowAmbiguousTypes #-}
32{-# LANGUAGE ConstraintKinds #-}
43{-# LANGUAGE DataKinds #-}
@@ -9,6 +8,7 @@
98{-# LANGUAGE MultiParamTypeClasses #-}
109{-# LANGUAGE OverloadedStrings #-}
1110{-# LANGUAGE PolyKinds #-}
11+{-# LANGUAGE QuantifiedConstraints #-}
1212{-# LANGUAGE RankNTypes #-}
1313{-# LANGUAGE ScopedTypeVariables #-}
1414{-# LANGUAGE TupleSections #-}
@@ -17,14 +17,6 @@
1717{-# LANGUAGE TypeOperators #-}
1818{-# LANGUAGE UndecidableInstances #-}
1919
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−
2820module Servant.Server.Internal
2921 ( module Servant.Server.Internal
3022 , module Servant.Server.Internal.BasicAuth
@@ -111,12 +103,10 @@ import Servant.Server.Internal.RouteResult
111103import Servant.Server.Internal.RoutingApplication
112104import Servant.Server.Internal.ServerError
113105
114−#ifdef HAS_TYPE_ERROR
115106import GHC.TypeLits
116107 (ErrorMessage (..), TypeError)
117108import Servant.API.TypeLevel
118109 (AtLeastOneFragment, FragmentUnique)
119−#endif
120110
121111class HasServer api context where
122112 type ServerT api (m :: * -> *) :: *
@@ -794,7 +784,7 @@ instance ( KnownSymbol realm
794784-- * helpers
795785
796786ct_wildcard :: B.ByteString
797−ct_wildcard = "*" <> "/" <> "*" -- Because CPP
787+ct_wildcard = "*" <> "/" <> "*"
798788
799789getAcceptHeader :: Request -> AcceptHeader
800790getAcceptHeader = AcceptHeader . fromMaybe ct_wildcard . lookup hAccept . requestHeaders
@@ -825,7 +815,6 @@ instance (HasContextEntry context (NamedContext name subContext), HasServer subA
825815-- TypeError helpers
826816-------------------------------------------------------------------------------
827817
828−#ifdef HAS_TYPE_ERROR
829818-- | This instance catches mistakes when there are non-saturated
830819-- type applications on LHS of ':>'.
831820--
@@ -888,7 +877,6 @@ type HasServerArrowTypeError a b =
888877 ':$$: 'ShowType a
889878 ':$$: 'Text "and"
890879 ':$$: 'ShowType b
891−#endif
892880
893881-- | Ignore @'Fragment'@ in server handlers.
894882-- See <https://ietf.org/rfc/rfc2616.html#section-15.1.3> for more details.
@@ -901,11 +889,7 @@ type HasServerArrowTypeError a b =
901889-- > server = getBooks
902890-- > where getBooks :: Handler [Book]
903891-- > getBooks = ...return all books...
904−#ifdef HAS_TYPE_ERROR
905892instance (AtLeastOneFragment api, FragmentUnique (Fragment a1 :> api), HasServer api context)
906−#else
907−instance (HasServer api context)
908−#endif
909893 => HasServer (Fragment a1 :> api) context where
910894 type ServerT (Fragment a1 :> api) m = ServerT api m
911895
@@ -924,8 +908,6 @@ instance GenericMode (AsServerT m) where
924908type AsServer = AsServerT Handler
925909
926910
927−#if __GLASGOW_HASKELL__ >= 806
928−
929911-- | Set of constraints required to convert to / from vanilla server types.
930912type GServerConstraints api m =
931913 ( ToServant api (AsServerT m) ~ ServerT (ToServantApi api) m
@@ -986,5 +968,3 @@ instance
986968 toServant server
987969 servantSrvN :: ServerT (ToServantApi api) n =
988970 hoistServerWithContext (Proxy @(ToServantApi api)) pctx nat servantSrvM
989−
990−#endif
servant/src/Servant/Links.hs+1−7
@@ -1,22 +1,18 @@
11{-# LANGUAGE AllowAmbiguousTypes #-}
22{-# LANGUAGE ConstraintKinds #-}
3−{-# LANGUAGE CPP #-}
43{-# LANGUAGE DataKinds #-}
54{-# LANGUAGE FlexibleContexts #-}
65{-# LANGUAGE FlexibleInstances #-}
76{-# LANGUAGE FunctionalDependencies #-}
87{-# LANGUAGE InstanceSigs #-}
98{-# LANGUAGE PolyKinds #-}
9+{-# LANGUAGE QuantifiedConstraints #-}
1010{-# LANGUAGE ScopedTypeVariables #-}
1111{-# LANGUAGE TypeApplications #-}
1212{-# LANGUAGE TypeFamilies #-}
1313{-# LANGUAGE TypeOperators #-}
1414{-# LANGUAGE UndecidableInstances #-}
1515
16−#if __GLASGOW_HASKELL__ >= 806
17−{-# LANGUAGE QuantifiedConstraints #-}
18−#endif
19−
2016{-# OPTIONS_HADDOCK not-home #-}
2117
2218-- | Type safe generation of internal links.
@@ -593,7 +589,6 @@ instance HasLink (UVerb m ct a) where
593589 toLink toA _ = toA
594590-- Instance for NamedRoutes combinator
595591
596−#if __GLASGOW_HASKELL__ >= 806
597592type GLinkConstraints routes a =
598593 ( MkLink (ToServant routes AsApi) a ~ ToServant routes (AsLink a)
599594 , GenericServant routes (AsLink a)
@@ -620,7 +615,6 @@ instance
620615
621616 toLink toA _ l = case proof @routes @a of
622617 Dict -> fromServant $ toLink toA (Proxy @(ToServantApi routes)) l
623−#endif
624618
625619-- AuthProtext instances
626620instance HasLink sub => HasLink (AuthProtect tag :> sub) where