Skip to content

Commit 575aa70

Browse files
author
Gaël Deest
committed
Cleanup
1 parent d81c8d9 commit 575aa70

File tree

5 files changed

+13
-54
lines changed

5 files changed

+13
-54
lines changed

servant-client-core/servant-client-core.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,19 @@
11
{-# LANGUAGE ConstraintKinds #-}
2-
{-# LANGUAGE CPP #-}
32
{-# LANGUAGE DataKinds #-}
43
{-# LANGUAGE FlexibleContexts #-}
54
{-# LANGUAGE FlexibleInstances #-}
65
{-# LANGUAGE InstanceSigs #-}
76
{-# LANGUAGE MultiParamTypeClasses #-}
87
{-# LANGUAGE OverloadedStrings #-}
98
{-# LANGUAGE PolyKinds #-}
9+
{-# LANGUAGE QuantifiedConstraints #-}
1010
{-# LANGUAGE RankNTypes #-}
1111
{-# LANGUAGE ScopedTypeVariables #-}
1212
{-# LANGUAGE TypeApplications #-}
1313
{-# LANGUAGE TypeFamilies #-}
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-
2517
module 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
808799
instance (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 :: * -> *)
833821
instance GenericMode (AsClientT m) where
834822
type AsClientT m :- api = Client m api
835823

836-
#if __GLASGOW_HASKELL__ >= 806
837824

838825
type 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-
878863
infixl 1 //
879864
infixl 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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
2820
module Servant.Server.Internal
2921
( module Servant.Server.Internal
3022
, module Servant.Server.Internal.BasicAuth
@@ -111,12 +103,10 @@ import Servant.Server.Internal.RouteResult
111103
import Servant.Server.Internal.RoutingApplication
112104
import Servant.Server.Internal.ServerError
113105

114-
#ifdef HAS_TYPE_ERROR
115106
import GHC.TypeLits
116107
(ErrorMessage (..), TypeError)
117108
import Servant.API.TypeLevel
118109
(AtLeastOneFragment, FragmentUnique)
119-
#endif
120110

121111
class HasServer api context where
122112
type ServerT api (m :: * -> *) :: *
@@ -794,7 +784,7 @@ instance ( KnownSymbol realm
794784
-- * helpers
795785

796786
ct_wildcard :: B.ByteString
797-
ct_wildcard = "*" <> "/" <> "*" -- Because CPP
787+
ct_wildcard = "*" <> "/" <> "*"
798788

799789
getAcceptHeader :: Request -> AcceptHeader
800790
getAcceptHeader = 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
905892
instance (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
924908
type AsServer = AsServerT Handler
925909

926910

927-
#if __GLASGOW_HASKELL__ >= 806
928-
929911
-- | Set of constraints required to convert to / from vanilla server types.
930912
type 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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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
597592
type 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
626620
instance HasLink sub => HasLink (AuthProtect tag :> sub) where

0 commit comments

Comments
 (0)