git.iko.soy/typeable/servant
on master help sign in
Code reorganization
fca5955Gaël Deest
servant-client-core/src/Servant/Client/Core/HasClient.hs+56−1
@@ -18,10 +18,15 @@
18#define HAS_TYPE_ERROR
18#define HAS_TYPE_ERROR
19#endif
19#endif
20
20
21+#if __GLASGOW_HASKELL__ >= 806
22+{-# LANGUAGE QuantifiedConstraints #-}
23+#endif
24+
21module Servant.Client.Core.HasClient (
25module Servant.Client.Core.HasClient (
22 clientIn,
26 clientIn,
23 HasClient (..),
27 HasClient (..),
24 EmptyClient (..),
28 EmptyClient (..),
29+ AsClientT,
25 foldMapUnion,
30 foldMapUnion,
26 matchUnion,
31 matchUnion,
27 ) where
32 ) where
@@ -39,6 +44,7 @@ import Data.ByteString.Builder
39import qualified Data.ByteString.Lazy as BL
44import qualified Data.ByteString.Lazy as BL
40import Data.Either
45import Data.Either
41 (partitionEithers)
46 (partitionEithers)
47+import Data.Constraint (Dict(..))
42import Data.Foldable
48import Data.Foldable
43 (toList)
49 (toList)
44import Data.List
50import Data.List
@@ -79,7 +85,10 @@ import Servant.API
79 ReflectMethod (..), RemoteHost, ReqBody', SBoolI, Stream,
85 ReflectMethod (..), RemoteHost, ReqBody', SBoolI, Stream,
80 StreamBody', Summary, ToHttpApiData, ToSourceIO (..), Vault,
86 StreamBody', Summary, ToHttpApiData, ToSourceIO (..), Vault,
81 Verb, WithNamedContext, WithStatus (..), contentType, getHeadersHList,
87 Verb, WithNamedContext, WithStatus (..), contentType, getHeadersHList,
82− getResponse, toEncodedUrlPiece, toUrlPiece)
88+ getResponse, toEncodedUrlPiece, toUrlPiece, NamedRoutes)
89+import Servant.API.Generic
90+ (GenericMode(..), ToServant, ToServantApi
91+ , GenericServant, toServant, fromServant)
83import Servant.API.ContentTypes
92import Servant.API.ContentTypes
84 (contentTypes, AllMime (allMime), AllMimeUnrender (allMimeUnrender))
93 (contentTypes, AllMime (allMime), AllMimeUnrender (allMimeUnrender))
85import Servant.API.TypeLevel (FragmentUnique, AtLeastOneFragment)
94import Servant.API.TypeLevel (FragmentUnique, AtLeastOneFragment)
@@ -816,6 +825,52 @@ instance HasClient m api => HasClient m (BasicAuth realm usr :> api) where
816 hoistClientMonad pm _ f cl = \bauth ->
825 hoistClientMonad pm _ f cl = \bauth ->
817 hoistClientMonad pm (Proxy :: Proxy api) f (cl bauth)
826 hoistClientMonad pm (Proxy :: Proxy api) f (cl bauth)
818
827
828+-- | A type that specifies that an API record contains a client implementation.
829+data AsClientT (m :: * -> *)
830+instance GenericMode (AsClientT m) where
831+ type AsClientT m :- api = Client m api
832+
833+#if __GLASGOW_HASKELL__ >= 806
834+
835+type GClientConstraints api m =
836+ ( GenericServant api (AsClientT m)
837+ , Client m (ToServantApi api) ~ ToServant api (AsClientT m)
838+ )
839+
840+class GClient (api :: * -> *) m where
841+ proof :: Dict (GClientConstraints api m)
842+
843+instance GClientConstraints api m => GClient api m where
844+ proof = Dict
845+
846+instance
847+ ( forall n. GClient api n
848+ , HasClient m (ToServantApi api)
849+ , RunClient m
850+ )
851+ => HasClient m (NamedRoutes api) where
852+ type Client m (NamedRoutes api) = api (AsClientT m)
853+
854+ clientWithRoute :: Proxy m -> Proxy (NamedRoutes api) -> Request -> Client m (NamedRoutes api)
855+ clientWithRoute pm _ request =
856+ case proof @api @m of
857+ Dict -> fromServant $ clientWithRoute pm (Proxy @(ToServantApi api)) request
858+
859+ hoistClientMonad
860+ :: forall ma mb.
861+ Proxy m
862+ -> Proxy (NamedRoutes api)
863+ -> (forall x. ma x -> mb x)
864+ -> Client ma (NamedRoutes api)
865+ -> Client mb (NamedRoutes api)
866+ hoistClientMonad _ _ nat clientA =
867+ case (proof @api @ma, proof @api @mb) of
868+ (Dict, Dict) ->
869+ fromServant @api @(AsClientT mb) $
870+ hoistClientMonad @m @(ToServantApi api) @ma @mb Proxy Proxy nat $
871+ toServant @api @(AsClientT ma) clientA
872+
873+#endif
819
874
820
875
821{- Note [Non-Empty Content Types]
876{- Note [Non-Empty Content Types]
servant-client-core/src/Servant/Client/Generic.hs+1−59
@@ -1,20 +1,9 @@
1{-# OPTIONS_GHC -fno-warn-orphans #-}
1{-# OPTIONS_GHC -fno-warn-orphans #-}
2−{-# LANGUAGE ConstraintKinds #-}
3−{-# LANGUAGE CPP #-}
4{-# LANGUAGE FlexibleContexts #-}
2{-# LANGUAGE FlexibleContexts #-}
5−{-# LANGUAGE FlexibleInstances #-}
6−{-# LANGUAGE InstanceSigs #-}
7{-# LANGUAGE KindSignatures #-}
3{-# LANGUAGE KindSignatures #-}
8−{-# LANGUAGE MultiParamTypeClasses #-}
9{-# LANGUAGE RankNTypes #-}
4{-# LANGUAGE RankNTypes #-}
10{-# LANGUAGE ScopedTypeVariables #-}
5{-# LANGUAGE ScopedTypeVariables #-}
11−{-# LANGUAGE TypeApplications #-}
12{-# LANGUAGE TypeFamilies #-}
6{-# LANGUAGE TypeFamilies #-}
13−{-# LANGUAGE UndecidableInstances #-}
14−
15−#if __GLASGOW_HASKELL__ >= 806
16−{-# LANGUAGE QuantifiedConstraints #-}
17−#endif
18
7
19module Servant.Client.Generic (
8module Servant.Client.Generic (
20 AsClientT,
9 AsClientT,
@@ -22,17 +11,12 @@ module Servant.Client.Generic (
22 genericClientHoist,
11 genericClientHoist,
23 ) where
12 ) where
24
13
25−import Data.Constraint (Dict(..))
26import Data.Proxy
14import Data.Proxy
27 (Proxy (..))
15 (Proxy (..))
28
16
29import Servant.API.Generic
17import Servant.API.Generic
30import Servant.Client.Core
18import Servant.Client.Core
31−
19+import Servant.Client.Core.HasClient (AsClientT)
32−-- | A type that specifies that an API record contains a client implementation.
33−data AsClientT (m :: * -> *)
34−instance GenericMode (AsClientT m) where
35− type AsClientT m :- api = Client m api
36
20
37-- | Generate a record of client functions.
21-- | Generate a record of client functions.
38genericClient
22genericClient
@@ -62,45 +46,3 @@ genericClientHoist nt
62 where
46 where
63 m = Proxy :: Proxy m
47 m = Proxy :: Proxy m
64 api = Proxy :: Proxy (ToServantApi routes)
48 api = Proxy :: Proxy (ToServantApi routes)
65−
66−#if __GLASGOW_HASKELL__ >= 806
67−
68−type GClientConstraints api m =
69− ( GenericServant api (AsClientT m)
70− , Client m (ToServantApi api) ~ ToServant api (AsClientT m)
71− )
72−
73−class GClient (api :: * -> *) m where
74− proof :: Dict (GClientConstraints api m)
75−
76−instance GClientConstraints api m => GClient api m where
77− proof = Dict
78−
79−instance
80− ( forall n. GClient api n
81− , HasClient m (ToServantApi api)
82− , RunClient m
83− )
84− => HasClient m (NamedRoutes api) where
85− type Client m (NamedRoutes api) = api (AsClientT m)
86−
87− clientWithRoute :: Proxy m -> Proxy (NamedRoutes api) -> Request -> Client m (NamedRoutes api)
88− clientWithRoute pm _ request =
89− case proof @api @m of
90− Dict -> fromServant $ clientWithRoute pm (Proxy @(ToServantApi api)) request
91−
92− hoistClientMonad
93− :: forall ma mb.
94− Proxy m
95− -> Proxy (NamedRoutes api)
96− -> (forall x. ma x -> mb x)
97− -> Client ma (NamedRoutes api)
98− -> Client mb (NamedRoutes api)
99− hoistClientMonad _ _ nat clientA =
100− case (proof @api @ma, proof @api @mb) of
101− (Dict, Dict) ->
102− fromServant @api @(AsClientT mb) $
103− hoistClientMonad @m @(ToServantApi api) @ma @mb Proxy Proxy nat $
104− toServant @api @(AsClientT ma) clientA
105−
106−#endif
servant-server/src/Servant/Server/Generic.hs+2−95
@@ -1,25 +1,9 @@
1−{-# OPTIONS_GHC -fno-warn-orphans #-}
2−{-# LANGUAGE AllowAmbiguousTypes #-}
3−{-# LANGUAGE ConstraintKinds #-}
4−{-# LANGUAGE CPP #-}
5{-# LANGUAGE DataKinds #-}
1{-# LANGUAGE DataKinds #-}
6−{-# LANGUAGE DefaultSignatures #-}
7{-# LANGUAGE FlexibleContexts #-}
2{-# LANGUAGE FlexibleContexts #-}
8−{-# LANGUAGE FlexibleInstances #-}
9−{-# LANGUAGE InstanceSigs #-}
10−{-# LANGUAGE KindSignatures #-}
11−{-# LANGUAGE MultiParamTypeClasses #-}
12−{-# LANGUAGE QuantifiedConstraints #-}
13{-# LANGUAGE RankNTypes #-}
3{-# LANGUAGE RankNTypes #-}
14{-# LANGUAGE ScopedTypeVariables #-}
4{-# LANGUAGE ScopedTypeVariables #-}
15−{-# LANGUAGE TypeApplications #-}
16{-# LANGUAGE TypeFamilies #-}
5{-# LANGUAGE TypeFamilies #-}
17{-# LANGUAGE TypeOperators #-}
6{-# LANGUAGE TypeOperators #-}
18−{-# LANGUAGE UndecidableInstances #-}
19−
20−#if __GLASGOW_HASKELL__ >= 806
21−{-# LANGUAGE QuantifiedConstraints #-}
22−#endif
23
7
24-- | @since 0.14.1
8-- | @since 0.14.1
25module Servant.Server.Generic (
9module Servant.Server.Generic (
@@ -29,29 +13,16 @@ module Servant.Server.Generic (
29 genericServeT,
13 genericServeT,
30 genericServeTWithContext,
14 genericServeTWithContext,
31 genericServer,
15 genericServer,
32− genericServerT,
16+ genericServerT
33− -- * Internal machinery
34− GServerConstraints,
35− GServer,
36− -- * Re-exports
37− NamedRoutes
38 ) where
17 ) where
39
18
40−import Data.Constraint
41import Data.Proxy
19import Data.Proxy
42 (Proxy (..))
20 (Proxy (..))
43
21
44−import Servant.API.Generic
45import Servant.Server
22import Servant.Server
23+import Servant.API.Generic
46import Servant.Server.Internal
24import Servant.Server.Internal
47
25
48−-- | A type that specifies that an API record contains a server implementation.
49−data AsServerT (m :: * -> *)
50−instance GenericMode (AsServerT m) where
51− type AsServerT m :- api = ServerT api m
52−
53−type AsServer = AsServerT Handler
54−
55-- | Transform a record of routes into a WAI 'Application'.
26-- | Transform a record of routes into a WAI 'Application'.
56genericServe
27genericServe
57 :: forall routes.
28 :: forall routes.
@@ -119,67 +90,3 @@ genericServerT
119 -> ToServant routes (AsServerT m)
90 -> ToServant routes (AsServerT m)
120genericServerT = toServant
91genericServerT = toServant
121
92
122−#if __GLASGOW_HASKELL__ >= 806
123−
124−-- | Set of constraints required to convert to / from vanilla server types.
125−type GServerConstraints api m =
126− ( ToServant api (AsServerT m) ~ ServerT (ToServantApi api) m
127− , GServantProduct (Rep (api (AsServerT m)))
128− )
129−
130−-- | This class is a necessary evil: in the implementation of 'HasServer' for
131−-- @'NamedRoutes' api@, we essentially need the quantified constraint @forall
132−-- m. 'GServerConstraints' m@ to hold.
133−--
134−-- We cannot require do that directly as the definition of 'GServerConstraints'
135−-- contains type family applications ('Rep' and 'ServerT'). The trick is to hide
136−-- those type family applications behind a typeclass providing evidence for
137−-- @'GServerConstraints' api m@ in the form of a dictionary, and require that
138−-- @forall m. 'GServer' api m@ instead.
139−--
140−-- Users shouldn't have to worry about this class, as the only possible instance
141−-- is provided in this module for all record APIs.
142−
143−class GServer (api :: * -> *) (m :: * -> *) where
144− proof :: Dict (GServerConstraints api m)
145−
146−instance
147− ( ToServant api (AsServerT m) ~ ServerT (ToServantApi api) m
148− , GServantProduct (Rep (api (AsServerT m)))
149− ) => GServer api m where
150− proof = Dict
151−
152−instance
153− ( HasServer (ToServantApi api) context
154− , forall m. Generic (api (AsServerT m))
155− , forall m. GServer api m
156− ) => HasServer (NamedRoutes api) context where
157−
158− type ServerT (NamedRoutes api) m = api (AsServerT m)
159−
160− route
161− :: Proxy (NamedRoutes api)
162− -> Context context
163− -> Delayed env (api (AsServerT Handler))
164− -> Router env
165− route _ ctx delayed =
166− case proof @api @Handler of
167− Dict -> route (Proxy @(ToServantApi api)) ctx (toServant <$> delayed)
168−
169− hoistServerWithContext
170− :: forall m n. Proxy (NamedRoutes api)
171− -> Proxy context
172− -> (forall x. m x -> n x)
173− -> api (AsServerT m)
174− -> api (AsServerT n)
175− hoistServerWithContext _ pctx nat server =
176− case (proof @api @m, proof @api @n) of
177− (Dict, Dict) ->
178− fromServant servantSrvN
179− where
180− servantSrvM :: ServerT (ToServantApi api) m =
181− toServant server
182− servantSrvN :: ServerT (ToServantApi api) n =
183− hoistServerWithContext (Proxy @(ToServantApi api)) pctx nat servantSrvM
184−
185−#endif
servant-server/src/Servant/Server/Internal.hs+84−1
@@ -1,15 +1,18 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
2+{-# LANGUAGE AllowAmbiguousTypes #-}
2{-# LANGUAGE ConstraintKinds #-}
3{-# LANGUAGE ConstraintKinds #-}
3{-# LANGUAGE DataKinds #-}
4{-# LANGUAGE DataKinds #-}
4{-# LANGUAGE DeriveDataTypeable #-}
5{-# LANGUAGE DeriveDataTypeable #-}
5{-# LANGUAGE FlexibleContexts #-}
6{-# LANGUAGE FlexibleContexts #-}
6{-# LANGUAGE FlexibleInstances #-}
7{-# LANGUAGE FlexibleInstances #-}
8+{-# LANGUAGE InstanceSigs #-}
7{-# LANGUAGE MultiParamTypeClasses #-}
9{-# LANGUAGE MultiParamTypeClasses #-}
8{-# LANGUAGE OverloadedStrings #-}
10{-# LANGUAGE OverloadedStrings #-}
9{-# LANGUAGE PolyKinds #-}
11{-# LANGUAGE PolyKinds #-}
10{-# LANGUAGE RankNTypes #-}
12{-# LANGUAGE RankNTypes #-}
11{-# LANGUAGE ScopedTypeVariables #-}
13{-# LANGUAGE ScopedTypeVariables #-}
12{-# LANGUAGE TupleSections #-}
14{-# LANGUAGE TupleSections #-}
15+{-# LANGUAGE TypeApplications #-}
13{-# LANGUAGE TypeFamilies #-}
16{-# LANGUAGE TypeFamilies #-}
14{-# LANGUAGE TypeOperators #-}
17{-# LANGUAGE TypeOperators #-}
15{-# LANGUAGE UndecidableInstances #-}
18{-# LANGUAGE UndecidableInstances #-}
@@ -18,6 +21,10 @@
18#define HAS_TYPE_ERROR
21#define HAS_TYPE_ERROR
19#endif
22#endif
20
23
24+#if __GLASGOW_HASKELL__ >= 806
25+{-# LANGUAGE QuantifiedConstraints #-}
26+#endif
27+
21module Servant.Server.Internal
28module Servant.Server.Internal
22 ( module Servant.Server.Internal
29 ( module Servant.Server.Internal
23 , module Servant.Server.Internal.BasicAuth
30 , module Servant.Server.Internal.BasicAuth
@@ -42,6 +49,7 @@ import qualified Data.ByteString as B
42import qualified Data.ByteString.Builder as BB
49import qualified Data.ByteString.Builder as BB
43import qualified Data.ByteString.Char8 as BC8
50import qualified Data.ByteString.Char8 as BC8
44import qualified Data.ByteString.Lazy as BL
51import qualified Data.ByteString.Lazy as BL
52+import Data.Constraint (Dict(..))
45import Data.Either
53import Data.Either
46 (partitionEithers)
54 (partitionEithers)
47import Data.Maybe
55import Data.Maybe
@@ -54,6 +62,7 @@ import Data.Tagged
54 (Tagged (..), retag, untag)
62 (Tagged (..), retag, untag)
55import qualified Data.Text as T
63import qualified Data.Text as T
56import Data.Typeable
64import Data.Typeable
65+import GHC.Generics
57import GHC.TypeLits
66import GHC.TypeLits
58 (KnownNat, KnownSymbol, natVal, symbolVal)
67 (KnownNat, KnownSymbol, natVal, symbolVal)
59import qualified Network.HTTP.Media as NHM
68import qualified Network.HTTP.Media as NHM
@@ -75,7 +84,8 @@ import Servant.API
75 QueryParam', QueryParams, Raw, ReflectMethod (reflectMethod),
84 QueryParam', QueryParams, Raw, ReflectMethod (reflectMethod),
76 RemoteHost, ReqBody', SBool (..), SBoolI (..), SourceIO,
85 RemoteHost, ReqBody', SBool (..), SBoolI (..), SourceIO,
77 Stream, StreamBody', Summary, ToSourceIO (..), Vault, Verb,
86 Stream, StreamBody', Summary, ToSourceIO (..), Vault, Verb,
78− WithNamedContext)
87+ WithNamedContext, NamedRoutes)
88+import Servant.API.Generic (GenericMode(..), ToServant, ToServantApi, GServantProduct, toServant, fromServant)
79import Servant.API.ContentTypes
89import Servant.API.ContentTypes
80 (AcceptHeader (..), AllCTRender (..), AllCTUnrender (..),
90 (AcceptHeader (..), AllCTRender (..), AllCTUnrender (..),
81 AllMime, MimeRender (..), MimeUnrender (..), NoContent,
91 AllMime, MimeRender (..), MimeUnrender (..), NoContent,
@@ -905,3 +915,76 @@ instance (HasServer api context)
905
915
906-- $setup
916-- $setup
907-- >>> import Servant
917-- >>> import Servant
918+
919+-- | A type that specifies that an API record contains a server implementation.
920+data AsServerT (m :: * -> *)
921+instance GenericMode (AsServerT m) where
922+ type AsServerT m :- api = ServerT api m
923+
924+type AsServer = AsServerT Handler
925+
926+
927+#if __GLASGOW_HASKELL__ >= 806
928+
929+-- | Set of constraints required to convert to / from vanilla server types.
930+type GServerConstraints api m =
931+ ( ToServant api (AsServerT m) ~ ServerT (ToServantApi api) m
932+ , GServantProduct (Rep (api (AsServerT m)))
933+ )
934+
935+-- | This class is a necessary evil: in the implementation of 'HasServer' for
936+-- @'NamedRoutes' api@, we essentially need the quantified constraint @forall
937+-- m. 'GServerConstraints' m@ to hold.
938+--
939+-- We cannot require do that directly as the definition of 'GServerConstraints'
940+-- contains type family applications ('Rep' and 'ServerT'). The trick is to hide
941+-- those type family applications behind a typeclass providing evidence for
942+-- @'GServerConstraints' api m@ in the form of a dictionary, and require that
943+-- @forall m. 'GServer' api m@ instead.
944+--
945+-- Users shouldn't have to worry about this class, as the only possible instance
946+-- is provided in this module for all record APIs.
947+
948+class GServer (api :: * -> *) (m :: * -> *) where
949+ proof :: Dict (GServerConstraints api m)
950+
951+instance
952+ ( ToServant api (AsServerT m) ~ ServerT (ToServantApi api) m
953+ , GServantProduct (Rep (api (AsServerT m)))
954+ ) => GServer api m where
955+ proof = Dict
956+
957+instance
958+ ( HasServer (ToServantApi api) context
959+ , forall m. Generic (api (AsServerT m))
960+ , forall m. GServer api m
961+ ) => HasServer (NamedRoutes api) context where
962+
963+ type ServerT (NamedRoutes api) m = api (AsServerT m)
964+
965+ route
966+ :: Proxy (NamedRoutes api)
967+ -> Context context
968+ -> Delayed env (api (AsServerT Handler))
969+ -> Router env
970+ route _ ctx delayed =
971+ case proof @api @Handler of
972+ Dict -> route (Proxy @(ToServantApi api)) ctx (toServant <$> delayed)
973+
974+ hoistServerWithContext
975+ :: forall m n. Proxy (NamedRoutes api)
976+ -> Proxy context
977+ -> (forall x. m x -> n x)
978+ -> api (AsServerT m)
979+ -> api (AsServerT n)
980+ hoistServerWithContext _ pctx nat server =
981+ case (proof @api @m, proof @api @n) of
982+ (Dict, Dict) ->
983+ fromServant servantSrvN
984+ where
985+ servantSrvM :: ServerT (ToServantApi api) m =
986+ toServant server
987+ servantSrvN :: ServerT (ToServantApi api) n =
988+ hoistServerWithContext (Proxy @(ToServantApi api)) pctx nat servantSrvM
989+
990+#endif
servant/servant.cabal+2−1
@@ -46,6 +46,7 @@ library
46 Servant.API.HttpVersion
46 Servant.API.HttpVersion
47 Servant.API.IsSecure
47 Servant.API.IsSecure
48 Servant.API.Modifiers
48 Servant.API.Modifiers
49+ Servant.API.NamedRoutes
49 Servant.API.QueryParam
50 Servant.API.QueryParam
50 Servant.API.Raw
51 Servant.API.Raw
51 Servant.API.RemoteHost
52 Servant.API.RemoteHost
@@ -80,7 +81,7 @@ library
80 build-depends:
81 build-depends:
81 base >= 4.9 && < 4.16
82 base >= 4.9 && < 4.16
82 , bytestring >= 0.10.8.1 && < 0.12
83 , bytestring >= 0.10.8.1 && < 0.12
83− , constraints
84+ , constraints >= 0.2
84 , mtl >= 2.2.2 && < 2.3
85 , mtl >= 2.2.2 && < 2.3
85 , sop-core >= 0.4.0.0 && < 0.6
86 , sop-core >= 0.4.0.0 && < 0.6
86 , transformers >= 0.5.2.0 && < 0.6
87 , transformers >= 0.5.2.0 && < 0.6
servant/src/Servant/API.hs+5
@@ -36,6 +36,9 @@ module Servant.API (
36 module Servant.API.Verbs,
36 module Servant.API.Verbs,
37 module Servant.API.UVerb,
37 module Servant.API.UVerb,
38
38
39+ -- * Sub-APIs defined as records of routes
40+ module Servant.API.NamedRoutes,
41+
39 -- * Streaming endpoints, distinguished by HTTP method
42 -- * Streaming endpoints, distinguished by HTTP method
40 module Servant.API.Stream,
43 module Servant.API.Stream,
41
44
@@ -130,6 +133,8 @@ import Servant.API.UVerb
130 Unique, WithStatus (..), inject, statusOf)
133 Unique, WithStatus (..), inject, statusOf)
131import Servant.API.Vault
134import Servant.API.Vault
132 (Vault)
135 (Vault)
136+import Servant.API.NamedRoutes
137+ (NamedRoutes)
133import Servant.API.Verbs
138import Servant.API.Verbs
134 (Delete, DeleteAccepted, DeleteNoContent,
139 (Delete, DeleteAccepted, DeleteNoContent,
135 DeleteNonAuthoritative, Get, GetAccepted, GetNoContent,
140 DeleteNonAuthoritative, Get, GetAccepted, GetNoContent,
servant/src/Servant/API/Generic.hs−5
@@ -37,8 +37,6 @@ module Servant.API.Generic (
37 ToServant,
37 ToServant,
38 toServant,
38 toServant,
39 fromServant,
39 fromServant,
40− -- * NamedRoutes combinator
41− NamedRoutes,
42 -- * AsApi
40 -- * AsApi
43 AsApi,
41 AsApi,
44 ToServantApi,
42 ToServantApi,
@@ -122,9 +120,6 @@ genericApi
122 -> Proxy (ToServantApi routes)
120 -> Proxy (ToServantApi routes)
123genericApi _ = Proxy
121genericApi _ = Proxy
124
122
125−-- | Combinator for embedding a record of named routes into a Servant API type.
126−data NamedRoutes (api :: * -> *)
127−
128-------------------------------------------------------------------------------
123-------------------------------------------------------------------------------
129-- Class
124-- Class
130-------------------------------------------------------------------------------
125-------------------------------------------------------------------------------
servant/src/Servant/API/NamedRoutes.hsnew file+10
@@ -0,0 +1,10 @@
1+{-# LANGUAGE KindSignatures #-}
2+{-# OPTIONS_HADDOCK not-home #-}
3+
4+module Servant.API.NamedRoutes (
5+ -- * NamedRoutes combinator
6+ NamedRoutes
7+ ) where
8+
9+-- | Combinator for embedding a record of named routes into a Servant API type.
10+data NamedRoutes (api :: * -> *)
servant/src/Servant/Links.hs+2
@@ -173,6 +173,8 @@ import Servant.API.IsSecure
173 (IsSecure)
173 (IsSecure)
174import Servant.API.Modifiers
174import Servant.API.Modifiers
175 (FoldRequired)
175 (FoldRequired)
176+import Servant.API.NamedRoutes
177+ (NamedRoutes)
176import Servant.API.QueryParam
178import Servant.API.QueryParam
177 (QueryFlag, QueryParam', QueryParams)
179 (QueryFlag, QueryParam', QueryParams)
178import Servant.API.Raw
180import Servant.API.Raw