git.iko.soy/typeable/servant
on master help sign in
7.10 changes
commitf82ca76f7d301c8752662baeb09fbc73ed3ff3a2 authorJulian K. Arni <jkarni@gmail.com> dateMon 20 Apr 2015, 19:52 (11 years ago) parentf4edddc
18 files changed+251−88
.travis.yml+12−4 scripts/shell.nix+11−6 scripts/test-all.sh+7−6 servant-client/src/Servant/Client.hs+66−31 servant-client/src/Servant/Common/Req.hs+4−1 servant-client/test/Servant/ClientSpec.hs+1−1 servant-client/test/Servant/Common/BaseUrlSpec.hs+3 servant-docs/src/Servant/Docs/Internal.hs+3 servant-jquery/src/Servant/JQuery/Internal.hs+11−8 servant-server/src/Servant/Server/Internal.hs+81−16 servant/servant.cabal+2−1 servant/src/Servant/API/Alternative.hs+3 servant/src/Servant/API/ContentTypes.hs+3 servant/src/Servant/API/ResponseHeaders.hs+14−3 servant/src/Servant/Common/Text.hs+8−1 servant/src/Servant/Utils/Links.hs+13−9 servant/test/Servant/API/ContentTypesSpec.hs+3 servant/test/Servant/Common/TextSpec.hs+6−1
.travis.yml+12−4
@@ -1,11 +1,19 @@
11language: haskell
22
3−ghc:
4− - 7.8
3+env:
4+ - CABALVER=1.18 GHCVER=7.8.4
5+ - CABALVER=1.22 GHCVER=7.10.1
6+
7+before_install:
8+ - travis_retry sudo add-apt-repository -y ppa:hvr/ghc
9+ - travis_retry sudo apt-get update
10+ - travis_retry sudo apt-get install cabal-install-$CABALVER ghc-$GHCVER
11+ - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
12+ - travis_retry cabal update
513
614install:
7− - ghc --version
8− - cabal --version
15+ - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
16+ - cabal --version
917
1018script:
1119 - ./scripts/test-all.sh
scripts/shell.nix+11−6
@@ -2,12 +2,17 @@
22# Also a good way of running the tests for all packages
33with (import <nixpkgs> {}).pkgs;
44let modifiedHaskellPackages = haskellngPackages.override {
5− overrides = self: super: {
6− servant = self.callPackage ../servant {};
7− servant-server = self.callPackage ../servant-server {};
8− servant-client = self.callPackage ../servant-client {};
9− servant-jquery = self.callPackage ../servant-jquery {};
10− servant-docs = self.callPackage ../servant-docs {};
5+ overrides = with haskell-ng.lib ; self: super: {
6+ servant = appendConfigureFlag ( self.callPackage ../servant {} )
7+ "--ghc-options=-Werror";
8+ servant-server = appendConfigureFlag (self.callPackage
9+ ../servant-server {}) "--ghc-options=-Werror";
10+ servant-client = appendConfigureFlag (self.callPackage
11+ ../servant-client {}) "--ghc-options=-Werror";
12+ servant-jquery = appendConfigureFlag (self.callPackage
13+ ../servant-jquery {}) "--ghc-options=-Werror";
14+ servant-docs = appendConfigureFlag (self.callPackage ../servant-docs
15+ {}) "--ghc-options=-Werror";
1116 };
1217 };
1318in modifiedHaskellPackages.ghcWithPackages ( p : with p ; [
scripts/test-all.sh+7−6
@@ -17,15 +17,16 @@ set -o errexit
1717DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
1818GHC_FLAGS="-Werror"
1919SOURCES_TXT="$( dirname $DIR)/sources.txt"
20+CABAL=${CABAL:-cabal}
2021
2122declare -a SOURCES
2223readarray -t SOURCES < "$SOURCES_TXT"
2324
2425
2526prepare_sandbox () {
26− cabal sandbox init
27+ $CABAL sandbox init
2728 for s in ${SOURCES[@]} ; do
28− (cd "$s" && cabal sandbox init --sandbox=../ && cabal sandbox add-source .)
29+ (cd "$s" && $CABAL sandbox init --sandbox=../ && $CABAL sandbox add-source .)
2930 done
3031}
3132
@@ -33,10 +34,10 @@ test_each () {
3334 for s in ${SOURCES[@]} ; do
3435 echo "Testing $s..."
3536 cd "$s"
36− cabal install --only-dependencies --enable-tests
37− cabal configure --enable-tests --ghc-options="$GHC_FLAGS"
38− cabal build
39− cabal test
37+ $CABAL install --only-dependencies --enable-tests
38+ $CABAL configure --enable-tests --ghc-options="$GHC_FLAGS"
39+ $CABAL build
40+ $CABAL test
4041 cd ..
4142 done
4243}
servant-client/src/Servant/Client.hs+66−31
@@ -1,12 +1,15 @@
1−{-# LANGUAGE DataKinds #-}
2−{-# LANGUAGE InstanceSigs #-}
3−{-# LANGUAGE TypeFamilies #-}
4−{-# LANGUAGE TypeOperators #-}
5−{-# LANGUAGE FlexibleContexts #-}
6−{-# LANGUAGE FlexibleInstances #-}
7−{-# LANGUAGE OverloadedStrings #-}
1+{-# LANGUAGE CPP #-}
2+{-# LANGUAGE DataKinds #-}
3+{-# LANGUAGE FlexibleContexts #-}
4+{-# LANGUAGE FlexibleInstances #-}
5+{-# LANGUAGE InstanceSigs #-}
6+{-# LANGUAGE OverloadedStrings #-}
7+{-# LANGUAGE ScopedTypeVariables #-}
8+{-# LANGUAGE TypeFamilies #-}
9+{-# LANGUAGE TypeOperators #-}
10+#if !MIN_VERSION_base(4,8,0)
811{-# LANGUAGE OverlappingInstances #-}
9−{-# LANGUAGE ScopedTypeVariables #-}
12+#endif
1013-- | This module provides 'client' which can automatically generate
1114-- querying functions for each endpoint just from the type representing your
1215-- API.
@@ -18,21 +21,21 @@ module Servant.Client
1821 , module Servant.Common.BaseUrl
1922 ) where
2023
21−import Control.Monad
22−import Control.Monad.Trans.Either
23−import Data.ByteString.Lazy (ByteString)
24−import Data.List
25−import Data.Proxy
26−import Data.String.Conversions
27−import Data.Text (unpack)
28−import GHC.TypeLits
29−import Network.HTTP.Client (Response)
30−import Network.HTTP.Media
31−import qualified Network.HTTP.Types as H
32−import Servant.API
33−import Servant.API.ContentTypes
34−import Servant.Common.BaseUrl
35−import Servant.Common.Req
24+import Control.Monad
25+import Control.Monad.Trans.Either
26+import Data.ByteString.Lazy (ByteString)
27+import Data.List
28+import Data.Proxy
29+import Data.String.Conversions
30+import Data.Text (unpack)
31+import GHC.TypeLits
32+import Network.HTTP.Client (Response)
33+import Network.HTTP.Media
34+import qualified Network.HTTP.Types as H
35+import Servant.API
36+import Servant.API.ContentTypes
37+import Servant.Common.BaseUrl
38+import Servant.Common.Req
3639
3740-- * Accessing APIs as a Client
3841
@@ -123,14 +126,22 @@ instance HasClient Delete where
123126-- side querying function that is created when calling 'client'
124127-- will just require an argument that specifies the scheme, host
125128-- and port to send the request to.
126−instance (MimeUnrender ct result) => HasClient (Get (ct ': cts) result) where
129+instance
130+#if MIN_VERSION_base(4,8,0)
131+ {-# OVERLAPPABLE #-}
132+#endif
133+ (MimeUnrender ct result) => HasClient (Get (ct ': cts) result) where
127134 type Client' (Get (ct ': cts) result) = BaseUrl -> EitherT ServantError IO result
128135 clientWithRoute Proxy req host =
129136 performRequestCT (Proxy :: Proxy ct) H.methodGet req [200, 203] host
130137
131138-- | If you have a 'Get xs ()' endpoint, the client expects a 204 No Content
132139-- HTTP header.
133−instance HasClient (Get (ct ': cts) ()) where
140+instance
141+#if MIN_VERSION_base(4,8,0)
142+ {-# OVERLAPPING #-}
143+#endif
144+ HasClient (Get (ct ': cts) ()) where
134145 type Client' (Get (ct ': cts) ()) = BaseUrl -> EitherT ServantError IO ()
135146 clientWithRoute Proxy req host =
136147 performRequestNoBody H.methodGet req [204] host
@@ -176,7 +187,11 @@ instance (KnownSymbol sym, ToText a, HasClient sublayout)
176187-- side querying function that is created when calling 'client'
177188-- will just require an argument that specifies the scheme, host
178189-- and port to send the request to.
179−instance (MimeUnrender ct a) => HasClient (Post (ct ': cts) a) where
190+instance
191+#if MIN_VERSION_base(4,8,0)
192+ {-# OVERLAPPABLE #-}
193+#endif
194+ (MimeUnrender ct a) => HasClient (Post (ct ': cts) a) where
180195 type Client' (Post (ct ': cts) a) = BaseUrl -> EitherT ServantError IO a
181196
182197 clientWithRoute Proxy req uri =
@@ -184,7 +199,11 @@ instance (MimeUnrender ct a) => HasClient (Post (ct ': cts) a) where
184199
185200-- | If you have a 'Post xs ()' endpoint, the client expects a 204 No Content
186201-- HTTP header.
187−instance HasClient (Post (ct ': cts) ()) where
202+instance
203+#if MIN_VERSION_base(4,8,0)
204+ {-# OVERLAPPING #-}
205+#endif
206+ HasClient (Post (ct ': cts) ()) where
188207 type Client' (Post (ct ': cts) ()) = BaseUrl -> EitherT ServantError IO ()
189208 clientWithRoute Proxy req host =
190209 void $ performRequestNoBody H.methodPost req [204] host
@@ -193,7 +212,11 @@ instance HasClient (Post (ct ': cts) ()) where
193212-- side querying function that is created when calling 'client'
194213-- will just require an argument that specifies the scheme, host
195214-- and port to send the request to.
196−instance (MimeUnrender ct a) => HasClient (Put (ct ': cts) a) where
215+instance
216+#if MIN_VERSION_base(4,8,0)
217+ {-# OVERLAPPABLE #-}
218+#endif
219+ (MimeUnrender ct a) => HasClient (Put (ct ': cts) a) where
197220 type Client' (Put (ct ': cts) a) = BaseUrl -> EitherT ServantError IO a
198221
199222 clientWithRoute Proxy req host =
@@ -201,7 +224,11 @@ instance (MimeUnrender ct a) => HasClient (Put (ct ': cts) a) where
201224
202225-- | If you have a 'Put xs ()' endpoint, the client expects a 204 No Content
203226-- HTTP header.
204−instance HasClient (Put (ct ': cts) ()) where
227+instance
228+#if MIN_VERSION_base(4,8,0)
229+ {-# OVERLAPPING #-}
230+#endif
231+ HasClient (Put (ct ': cts) ()) where
205232 type Client' (Put (ct ': cts) ()) = BaseUrl -> EitherT ServantError IO ()
206233 clientWithRoute Proxy req host =
207234 void $ performRequestNoBody H.methodPut req [204] host
@@ -210,7 +237,11 @@ instance HasClient (Put (ct ': cts) ()) where
210237-- side querying function that is created when calling 'client'
211238-- will just require an argument that specifies the scheme, host
212239-- and port to send the request to.
213−instance (MimeUnrender ct a) => HasClient (Patch (ct ': cts) a) where
240+instance
241+#if MIN_VERSION_base(4,8,0)
242+ {-# OVERLAPPABLE #-}
243+#endif
244+ (MimeUnrender ct a) => HasClient (Patch (ct ': cts) a) where
214245 type Client' (Patch (ct ': cts) a) = BaseUrl -> EitherT ServantError IO a
215246
216247 clientWithRoute Proxy req host =
@@ -218,7 +249,11 @@ instance (MimeUnrender ct a) => HasClient (Patch (ct ': cts) a) where
218249
219250-- | If you have a 'Patch xs ()' endpoint, the client expects a 204 No Content
220251-- HTTP header.
221−instance HasClient (Patch (ct ': cts) ()) where
252+instance
253+#if MIN_VERSION_base(4,8,0)
254+ {-# OVERLAPPING #-}
255+#endif
256+ HasClient (Patch (ct ': cts) ()) where
222257 type Client' (Patch (ct ': cts) ()) = BaseUrl -> EitherT ServantError IO ()
223258 clientWithRoute Proxy req host =
224259 void $ performRequestNoBody H.methodPatch req [204] host
servant-client/src/Servant/Common/Req.hs+4−1
@@ -1,8 +1,11 @@
1−{-# LANGUAGE OverloadedStrings #-}
1+{-# LANGUAGE CPP #-}
2+{-# LANGUAGE OverloadedStrings #-}
23{-# LANGUAGE ScopedTypeVariables #-}
34module Servant.Common.Req where
45
6+#if !MIN_VERSION_base(4,8,0)
57import Control.Applicative
8+#endif
69import Control.Exception
710import Control.Monad
811import Control.Monad.Catch (MonadThrow)
servant-client/test/Servant/ClientSpec.hs+1−1
@@ -340,6 +340,6 @@ pathGen :: Gen (NonEmptyList Char)
340340pathGen = fmap NonEmpty path
341341 where
342342 path = listOf1 $ elements $
343− filter (not . (`elem` "?%[]/#;")) $
343+ filter (not . (`elem` ("?%[]/#;" :: String))) $
344344 filter isPrint $
345345 map chr [0..127]
servant-client/test/Servant/Common/BaseUrlSpec.hs+3
@@ -1,7 +1,10 @@
1+{-# LANGUAGE CPP #-}
12{-# OPTIONS_GHC -fno-warn-orphans #-}
23module Servant.Common.BaseUrlSpec where
34
5+#if !MIN_VERSION_base(4,8,0)
46import Control.Applicative
7+#endif
58import Control.DeepSeq
69import Test.Hspec
710import Test.QuickCheck
servant-docs/src/Servant/Docs/Internal.hs+3
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE ConstraintKinds #-}
23{-# LANGUAGE DataKinds #-}
34{-# LANGUAGE DeriveGeneric #-}
@@ -13,7 +14,9 @@
1314{-# LANGUAGE UndecidableInstances #-}
1415module Servant.Docs.Internal where
1516
17+#if !MIN_VERSION_base(4,8,0)
1618import Control.Applicative
19+#endif
1720import Control.Lens
1821import Data.ByteString.Lazy.Char8 (ByteString)
1922import Data.Hashable
servant-jquery/src/Servant/JQuery/Internal.hs+11−8
@@ -1,15 +1,18 @@
1−{-# LANGUAGE DataKinds #-}
2−{-# LANGUAGE TypeFamilies #-}
3−{-# LANGUAGE TypeOperators #-}
4−{-# LANGUAGE ConstraintKinds #-}
5−{-# LANGUAGE TemplateHaskell #-}
6−{-# LANGUAGE FlexibleContexts #-}
7−{-# LANGUAGE FlexibleInstances #-}
8−{-# LANGUAGE ScopedTypeVariables #-}
1+{-# LANGUAGE CPP #-}
2+{-# LANGUAGE ConstraintKinds #-}
3+{-# LANGUAGE DataKinds #-}
4+{-# LANGUAGE FlexibleContexts #-}
5+{-# LANGUAGE FlexibleInstances #-}
6+{-# LANGUAGE ScopedTypeVariables #-}
7+{-# LANGUAGE TemplateHaskell #-}
8+{-# LANGUAGE TypeFamilies #-}
9+{-# LANGUAGE TypeOperators #-}
910{-# LANGUAGE UndecidableInstances #-}
1011module Servant.JQuery.Internal where
1112
13+#if !MIN_VERSION_base(4,8,0)
1214import Control.Applicative
15+#endif
1316import Control.Lens
1417import Data.Char (toLower)
1518import qualified Data.CharSet as Set
servant-server/src/Servant/Server/Internal.hs+81−16
@@ -1,12 +1,15 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE DataKinds #-}
23{-# LANGUAGE FlexibleContexts #-}
34{-# LANGUAGE FlexibleInstances #-}
4−{-# LANGUAGE OverlappingInstances #-}
55{-# LANGUAGE OverloadedStrings #-}
66{-# LANGUAGE PolyKinds #-}
77{-# LANGUAGE ScopedTypeVariables #-}
88{-# LANGUAGE TypeFamilies #-}
99{-# LANGUAGE TypeOperators #-}
10+#if !MIN_VERSION_base(4,8,0)
11+{-# LANGUAGE OverlappingInstances #-}
12+#endif
1013module Servant.Server.Internal where
1114
1215import Control.Applicative ((<$>))
@@ -280,8 +283,11 @@ instance HasServer Delete where
280283-- (returning a status code of 200). If there was no @Accept@ header or it
281284-- was @*/*@, we return encode using the first @Content-Type@ type on the
282285-- list.
283−instance ( AllCTRender ctypes a
284− ) => HasServer (Get ctypes a) where
286+instance
287+#if MIN_VERSION_base(4,8,0)
288+ {-# OVERLAPPABLE #-}
289+#endif
290+ ( AllCTRender ctypes a ) => HasServer (Get ctypes a) where
285291
286292 type ServerT' (Get ctypes a) m = m a
287293
@@ -302,8 +308,14 @@ instance ( AllCTRender ctypes a
302308 | otherwise = respond $ failWith NotFound
303309
304310-- '()' ==> 204 No Content
305−instance HasServer (Get ctypes ()) where
311+instance
312+#if MIN_VERSION_base(4,8,0)
313+ {-# OVERLAPPING #-}
314+#endif
315+ HasServer (Get ctypes ()) where
316+
306317 type ServerT' (Get ctypes ()) m = m ()
318+
307319 route Proxy action request respond
308320 | pathIsEmpty request && requestMethod request == methodGet = do
309321 e <- runEitherT action
@@ -316,8 +328,14 @@ instance HasServer (Get ctypes ()) where
316328 | otherwise = respond $ failWith NotFound
317329
318330-- Add response headers
319−instance ( AllCTRender ctypes v ) => HasServer (Get ctypes (Headers h v)) where
331+instance
332+#if MIN_VERSION_base(4,8,0)
333+ {-# OVERLAPPING #-}
334+#endif
335+ ( AllCTRender ctypes v ) => HasServer (Get ctypes (Headers h v)) where
336+
320337 type ServerT' (Get ctypes (Headers h v)) m = m (Headers h v)
338+
321339 route Proxy action request respond
322340 | pathIsEmpty request && requestMethod request == methodGet = do
323341 e <- runEitherT action
@@ -380,7 +398,11 @@ instance (KnownSymbol sym, FromText a, HasServer sublayout)
380398-- (returning a status code of 201). If there was no @Accept@ header or it
381399-- was @*/*@, we return encode using the first @Content-Type@ type on the
382400-- list.
383−instance ( AllCTRender ctypes a
401+instance
402+#if MIN_VERSION_base(4,8,0)
403+ {-# OVERLAPPABLE #-}
404+#endif
405+ ( AllCTRender ctypes a
384406 ) => HasServer (Post ctypes a) where
385407
386408 type ServerT' (Post ctypes a) m = m a
@@ -401,8 +423,14 @@ instance ( AllCTRender ctypes a
401423 respond $ failWith WrongMethod
402424 | otherwise = respond $ failWith NotFound
403425
404−instance HasServer (Post ctypes ()) where
426+instance
427+#if MIN_VERSION_base(4,8,0)
428+ {-# OVERLAPPING #-}
429+#endif
430+ HasServer (Post ctypes ()) where
431+
405432 type ServerT' (Post ctypes ()) m = m ()
433+
406434 route Proxy action request respond
407435 | pathIsEmpty request && requestMethod request == methodPost = do
408436 e <- runEitherT action
@@ -415,8 +443,14 @@ instance HasServer (Post ctypes ()) where
415443 | otherwise = respond $ failWith NotFound
416444
417445-- Add response headers
418−instance ( AllCTRender ctypes v ) => HasServer (Post ctypes (Headers h v)) where
446+instance
447+#if MIN_VERSION_base(4,8,0)
448+ {-# OVERLAPPING #-}
449+#endif
450+ ( AllCTRender ctypes v ) => HasServer (Post ctypes (Headers h v)) where
451+
419452 type ServerT' (Post ctypes (Headers h v)) m = m (Headers h v)
453+
420454 route Proxy action request respond
421455 | pathIsEmpty request && requestMethod request == methodPost = do
422456 e <- runEitherT action
@@ -447,8 +481,11 @@ instance ( AllCTRender ctypes v ) => HasServer (Post ctypes (Headers h v)) where
447481-- (returning a status code of 200). If there was no @Accept@ header or it
448482-- was @*/*@, we return encode using the first @Content-Type@ type on the
449483-- list.
450−instance ( AllCTRender ctypes a
451− ) => HasServer (Put ctypes a) where
484+instance
485+#if MIN_VERSION_base(4,8,0)
486+ {-# OVERLAPPABLE #-}
487+#endif
488+ ( AllCTRender ctypes a) => HasServer (Put ctypes a) where
452489
453490 type ServerT' (Put ctypes a) m = m a
454491
@@ -468,8 +505,14 @@ instance ( AllCTRender ctypes a
468505 respond $ failWith WrongMethod
469506 | otherwise = respond $ failWith NotFound
470507
471−instance HasServer (Put ctypes ()) where
508+instance
509+#if MIN_VERSION_base(4,8,0)
510+ {-# OVERLAPPING #-}
511+#endif
512+ HasServer (Put ctypes ()) where
513+
472514 type ServerT' (Put ctypes ()) m = m ()
515+
473516 route Proxy action request respond
474517 | pathIsEmpty request && requestMethod request == methodPut = do
475518 e <- runEitherT action
@@ -482,8 +525,14 @@ instance HasServer (Put ctypes ()) where
482525 | otherwise = respond $ failWith NotFound
483526
484527-- Add response headers
485−instance ( AllCTRender ctypes v ) => HasServer (Put ctypes (Headers h v)) where
528+instance
529+#if MIN_VERSION_base(4,8,0)
530+ {-# OVERLAPPING #-}
531+#endif
532+ ( AllCTRender ctypes v ) => HasServer (Put ctypes (Headers h v)) where
533+
486534 type ServerT' (Put ctypes (Headers h v)) m = m (Headers h v)
535+
487536 route Proxy action request respond
488537 | pathIsEmpty request && requestMethod request == methodPut = do
489538 e <- runEitherT action
@@ -512,8 +561,12 @@ instance ( AllCTRender ctypes v ) => HasServer (Put ctypes (Headers h v)) where
512561-- If successfully returning a value, we just require that its type has
513562-- a 'ToJSON' instance and servant takes care of encoding it for you,
514563-- yielding status code 200 along the way.
515−instance ( AllCTRender ctypes a
516− ) => HasServer (Patch ctypes a) where
564+instance
565+#if MIN_VERSION_base(4,8,0)
566+ {-# OVERLAPPABLE #-}
567+#endif
568+ ( AllCTRender ctypes a) => HasServer (Patch ctypes a) where
569+
517570 type ServerT' (Patch ctypes a) m = m a
518571
519572 route Proxy action request respond
@@ -532,8 +585,14 @@ instance ( AllCTRender ctypes a
532585 respond $ failWith WrongMethod
533586 | otherwise = respond $ failWith NotFound
534587
535−instance HasServer (Patch ctypes ()) where
588+instance
589+#if MIN_VERSION_base(4,8,0)
590+ {-# OVERLAPPING #-}
591+#endif
592+ HasServer (Patch ctypes ()) where
593+
536594 type ServerT' (Patch ctypes ()) m = m ()
595+
537596 route Proxy action request respond
538597 | pathIsEmpty request && requestMethod request == methodPatch = do
539598 e <- runEitherT action
@@ -546,8 +605,14 @@ instance HasServer (Patch ctypes ()) where
546605 | otherwise = respond $ failWith NotFound
547606
548607-- Add response headers
549−instance ( AllCTRender ctypes v ) => HasServer (Patch ctypes (Headers h v)) where
608+instance
609+#if MIN_VERSION_base(4,8,0)
610+ {-# OVERLAPPING #-}
611+#endif
612+ ( AllCTRender ctypes v ) => HasServer (Patch ctypes (Headers h v)) where
613+
550614 type ServerT' (Patch ctypes (Headers h v)) m = m (Headers h v)
615+
551616 route Proxy action request respond
552617 | pathIsEmpty request && requestMethod request == methodPatch = do
553618 e <- runEitherT action
servant/servant.cabal+2−1
@@ -59,7 +59,8 @@ library
5959 , network-uri >= 2.6
6060 hs-source-dirs: src
6161 default-language: Haskell2010
62− other-extensions: ConstraintKinds
62+ other-extensions: CPP
63+ , ConstraintKinds
6364 , DataKinds
6465 , DeriveDataTypeable
6566 , FlexibleInstances
servant/src/Servant/API/Alternative.hs+3
@@ -1,8 +1,11 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE DeriveDataTypeable #-}
23{-# LANGUAGE TypeOperators #-}
34module Servant.API.Alternative ((:<|>)(..)) where
45
6+#if !MIN_VERSION_base(4,8,0)
57import Data.Monoid (Monoid (..))
8+#endif
69import Data.Typeable (Typeable)
710-- | Union of two APIs, first takes precedence in case of overlap.
811--
servant/src/Servant/API/ContentTypes.hs+3
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE ConstraintKinds #-}
23{-# LANGUAGE DataKinds #-}
34{-# LANGUAGE DeriveDataTypeable #-}
@@ -63,7 +64,9 @@ module Servant.API.ContentTypes
6364 , eitherDecodeLenient
6465 ) where
6566
67+#if !MIN_VERSION_base(4,8,0)
6668import Control.Applicative ((<*))
69+#endif
6770import Control.Arrow (left)
6871import Control.Monad
6972import Data.Aeson (FromJSON, ToJSON, Value,
servant/src/Servant/API/ResponseHeaders.hs+14−3
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE DataKinds #-}
23{-# LANGUAGE DeriveFunctor #-}
34{-# LANGUAGE FlexibleContexts #-}
@@ -6,11 +7,13 @@
67{-# LANGUAGE GADTs #-}
78{-# LANGUAGE KindSignatures #-}
89{-# LANGUAGE MultiParamTypeClasses #-}
9−{-# LANGUAGE OverlappingInstances #-}
1010{-# LANGUAGE PolyKinds #-}
1111{-# LANGUAGE ScopedTypeVariables #-}
1212{-# LANGUAGE TypeOperators #-}
1313{-# LANGUAGE UndecidableInstances #-}
14+#if !MIN_VERSION_base(4,8,0)
15+{-# LANGUAGE OverlappingInstances #-}
16+#endif
1417
1518-- | This module provides facilities for adding headers to a response.
1619--
@@ -50,13 +53,21 @@ class AddHeader h v orig new
5053 | h v orig -> new, new -> h, new -> v, new -> orig where
5154 addHeader :: v -> orig -> new
5255
53−instance ( KnownSymbol h, ToByteString v
56+instance
57+#if MIN_VERSION_base(4,8,0)
58+ {-# OVERLAPPING #-}
59+#endif
60+ ( KnownSymbol h, ToByteString v
5461 ) => AddHeader h v (Headers (fst ': rest) a) (Headers (Header h v ': fst ': rest) a) where
5562 addHeader a (Headers resp heads) = Headers resp ((headerName, toByteString' a) : heads)
5663 where
5764 headerName = CI.mk . pack $ symbolVal (Proxy :: Proxy h)
5865
59−instance ( KnownSymbol h, ToByteString v
66+instance
67+#if MIN_VERSION_base(4,8,0)
68+ {-# OVERLAPPABLE #-}
69+#endif
70+ ( KnownSymbol h, ToByteString v
6071 , new ~ (Headers '[Header h v] a)
6172 ) => AddHeader h v a new where
6273 addHeader a resp = Headers resp [(headerName, toByteString' a)]
servant/src/Servant/Common/Text.hs+8−1
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE FlexibleInstances #-}
23{-# LANGUAGE OverloadedStrings #-}
34{-# LANGUAGE TypeSynonymInstances #-}
@@ -6,12 +7,18 @@ module Servant.Common.Text
67 , ToText(..)
78 ) where
89
10+#if !MIN_VERSION_base(4,8,0)
911import Control.Applicative ((<$>))
12+#endif
1013import Data.Int (Int16, Int32, Int64, Int8)
1114import Data.String.Conversions (cs)
1215import Data.Text (Text)
1316import Data.Text.Read (Reader, decimal, rational, signed)
14−import Data.Word (Word, Word16, Word32, Word64, Word8)
17+import Data.Word (Word16, Word32, Word64, Word8
18+#if !MIN_VERSION_base(4,8,0)
19+ , Word
20+#endif
21+ )
1522
1623-- | For getting values from url captures and query string parameters
1724-- Instances should obey:
servant/src/Servant/Utils/Links.hs+13−9
@@ -1,13 +1,13 @@
1−{-# LANGUAGE PolyKinds #-}
2−{-# LANGUAGE ConstraintKinds #-}
3−{-# LANGUAGE DataKinds #-}
4−{-# LANGUAGE FlexibleInstances #-}
1+{-# LANGUAGE CPP #-}
2+{-# LANGUAGE ConstraintKinds #-}
3+{-# LANGUAGE DataKinds #-}
4+{-# LANGUAGE FlexibleInstances #-}
55{-# LANGUAGE FunctionalDependencies #-}
6−{-# LANGUAGE PolyKinds #-}
7−{-# LANGUAGE ScopedTypeVariables #-}
8−{-# LANGUAGE TypeFamilies #-}
9−{-# LANGUAGE TypeOperators #-}
10−{-# LANGUAGE UndecidableInstances #-}
6+{-# LANGUAGE PolyKinds #-}
7+{-# LANGUAGE ScopedTypeVariables #-}
8+{-# LANGUAGE TypeFamilies #-}
9+{-# LANGUAGE TypeOperators #-}
10+{-# LANGUAGE UndecidableInstances #-}
1111
1212-- | Type safe generation of internal links.
1313--
@@ -104,7 +104,11 @@ module Servant.Utils.Links (
104104import Data.List
105105import Data.Proxy ( Proxy(..) )
106106import Data.Text (Text, unpack)
107+#if !MIN_VERSION_base(4,8,0)
107108import Data.Monoid ( Monoid(..), (<>) )
109+#else
110+import Data.Monoid ( (<>) )
111+#endif
108112import Network.URI ( URI(..), escapeURIString, isUnreserved )
109113import GHC.TypeLits ( KnownSymbol, symbolVal )
110114import GHC.Exts(Constraint)
servant/test/Servant/API/ContentTypesSpec.hs+3
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE DataKinds #-}
23{-# LANGUAGE DeriveGeneric #-}
34{-# LANGUAGE MultiParamTypeClasses #-}
@@ -5,7 +6,9 @@
56{-# OPTIONS_GHC -fno-warn-orphans #-}
67module Servant.API.ContentTypesSpec where
78
9+#if !MIN_VERSION_base(4,8,0)
810import Control.Applicative
11+#endif
912import Control.Arrow
1013import Data.Aeson
1114import Data.Aeson.Parser (jstring)
servant/test/Servant/Common/TextSpec.hs+6−1
@@ -1,8 +1,13 @@
1+{-# LANGUAGE CPP #-}
12module Servant.Common.TextSpec where
23
34import Data.Int (Int16, Int32, Int64, Int8)
45import Data.Text (Text)
5−import Data.Word (Word, Word16, Word32, Word64, Word8)
6+import Data.Word (Word16, Word32, Word64, Word8
7+#if !MIN_VERSION_base(4,8,0)
8+ , Word
9+#endif
10+ )
611import Servant.Common.Text
712import Test.Hspec
813import Test.QuickCheck