on master help sign in
7.10 changes
f82ca76Julian K. Arni
.travis.yml+12−4
@@ -1,11 +1,19 @@
1language: haskell
1language: haskell
2
2
3−ghc:
3+env:
4− - 7.8
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
5
13
6install:
14install:
7− - ghc --version
15+ - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
8− - cabal --version
16+ - cabal --version
9
17
10script:
18script:
11 - ./scripts/test-all.sh
19 - ./scripts/test-all.sh
scripts/shell.nix+11−6
@@ -2,12 +2,17 @@
2# Also a good way of running the tests for all packages
2# Also a good way of running the tests for all packages
3with (import <nixpkgs> {}).pkgs;
3with (import <nixpkgs> {}).pkgs;
4let modifiedHaskellPackages = haskellngPackages.override {
4let modifiedHaskellPackages = haskellngPackages.override {
5− overrides = self: super: {
5+ overrides = with haskell-ng.lib ; self: super: {
6− servant = self.callPackage ../servant {};
6+ servant = appendConfigureFlag ( self.callPackage ../servant {} )
7+ "--ghc-options=-Werror";
7− servant-server = self.callPackage ../servant-server {};
8+ servant-server = appendConfigureFlag (self.callPackage
9+ ../servant-server {}) "--ghc-options=-Werror";
8− servant-client = self.callPackage ../servant-client {};
10+ servant-client = appendConfigureFlag (self.callPackage
11+ ../servant-client {}) "--ghc-options=-Werror";
9− servant-jquery = self.callPackage ../servant-jquery {};
12+ servant-jquery = appendConfigureFlag (self.callPackage
13+ ../servant-jquery {}) "--ghc-options=-Werror";
10− servant-docs = self.callPackage ../servant-docs {};
14+ servant-docs = appendConfigureFlag (self.callPackage ../servant-docs
15+ {}) "--ghc-options=-Werror";
11 };
16 };
12 };
17 };
13in modifiedHaskellPackages.ghcWithPackages ( p : with p ; [
18in modifiedHaskellPackages.ghcWithPackages ( p : with p ; [
scripts/test-all.sh+7−6
@@ -17,15 +17,16 @@ set -o errexit
17DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
17DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
18GHC_FLAGS="-Werror"
18GHC_FLAGS="-Werror"
19SOURCES_TXT="$( dirname $DIR)/sources.txt"
19SOURCES_TXT="$( dirname $DIR)/sources.txt"
20+CABAL=${CABAL:-cabal}
20
21
21declare -a SOURCES
22declare -a SOURCES
22readarray -t SOURCES < "$SOURCES_TXT"
23readarray -t SOURCES < "$SOURCES_TXT"
23
24
24
25
25prepare_sandbox () {
26prepare_sandbox () {
26− cabal sandbox init
27+ $CABAL sandbox init
27 for s in ${SOURCES[@]} ; do
28 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 .)
29 done
30 done
30}
31}
31
32
@@ -33,10 +34,10 @@ test_each () {
33 for s in ${SOURCES[@]} ; do
34 for s in ${SOURCES[@]} ; do
34 echo "Testing $s..."
35 echo "Testing $s..."
35 cd "$s"
36 cd "$s"
36− cabal install --only-dependencies --enable-tests
37+ $CABAL install --only-dependencies --enable-tests
37− cabal configure --enable-tests --ghc-options="$GHC_FLAGS"
38+ $CABAL configure --enable-tests --ghc-options="$GHC_FLAGS"
38− cabal build
39+ $CABAL build
39− cabal test
40+ $CABAL test
40 cd ..
41 cd ..
41 done
42 done
42}
43}
servant-client/src/Servant/Client.hs+66−31
@@ -1,12 +1,15 @@
1−{-# LANGUAGE DataKinds #-}
1+{-# LANGUAGE CPP #-}
2−{-# LANGUAGE InstanceSigs #-}
2+{-# LANGUAGE DataKinds #-}
3−{-# LANGUAGE TypeFamilies #-}
4−{-# LANGUAGE TypeOperators #-}
5−{-# LANGUAGE FlexibleContexts #-}
3+{-# LANGUAGE FlexibleContexts #-}
6−{-# LANGUAGE FlexibleInstances #-}
4+{-# LANGUAGE FlexibleInstances #-}
5+{-# LANGUAGE InstanceSigs #-}
7−{-# LANGUAGE OverloadedStrings #-}
6+{-# LANGUAGE OverloadedStrings #-}
7+{-# LANGUAGE ScopedTypeVariables #-}
8+{-# LANGUAGE TypeFamilies #-}
9+{-# LANGUAGE TypeOperators #-}
10+#if !MIN_VERSION_base(4,8,0)
8{-# LANGUAGE OverlappingInstances #-}
11{-# LANGUAGE OverlappingInstances #-}
9−{-# LANGUAGE ScopedTypeVariables #-}
12+#endif
10-- | This module provides 'client' which can automatically generate
13-- | This module provides 'client' which can automatically generate
11-- querying functions for each endpoint just from the type representing your
14-- querying functions for each endpoint just from the type representing your
12-- API.
15-- API.
@@ -18,21 +21,21 @@ module Servant.Client
18 , module Servant.Common.BaseUrl
21 , module Servant.Common.BaseUrl
19 ) where
22 ) where
20
23
21−import Control.Monad
24+import Control.Monad
22−import Control.Monad.Trans.Either
25+import Control.Monad.Trans.Either
23−import Data.ByteString.Lazy (ByteString)
26+import Data.ByteString.Lazy (ByteString)
24−import Data.List
27+import Data.List
25−import Data.Proxy
28+import Data.Proxy
26−import Data.String.Conversions
29+import Data.String.Conversions
27−import Data.Text (unpack)
30+import Data.Text (unpack)
28−import GHC.TypeLits
31+import GHC.TypeLits
29−import Network.HTTP.Client (Response)
32+import Network.HTTP.Client (Response)
30−import Network.HTTP.Media
33+import Network.HTTP.Media
31−import qualified Network.HTTP.Types as H
34+import qualified Network.HTTP.Types as H
32−import Servant.API
35+import Servant.API
33−import Servant.API.ContentTypes
36+import Servant.API.ContentTypes
34−import Servant.Common.BaseUrl
37+import Servant.Common.BaseUrl
35−import Servant.Common.Req
38+import Servant.Common.Req
36
39
37-- * Accessing APIs as a Client
40-- * Accessing APIs as a Client
38
41
@@ -123,14 +126,22 @@ instance HasClient Delete where
123-- side querying function that is created when calling 'client'
126-- side querying function that is created when calling 'client'
124-- will just require an argument that specifies the scheme, host
127-- will just require an argument that specifies the scheme, host
125-- and port to send the request to.
128-- and port to send the request to.
129+instance
130+#if MIN_VERSION_base(4,8,0)
131+ {-# OVERLAPPABLE #-}
132+#endif
126−instance (MimeUnrender ct result) => HasClient (Get (ct ': cts) result) where
133+ (MimeUnrender ct result) => HasClient (Get (ct ': cts) result) where
127 type Client' (Get (ct ': cts) result) = BaseUrl -> EitherT ServantError IO result
134 type Client' (Get (ct ': cts) result) = BaseUrl -> EitherT ServantError IO result
128 clientWithRoute Proxy req host =
135 clientWithRoute Proxy req host =
129 performRequestCT (Proxy :: Proxy ct) H.methodGet req [200, 203] host
136 performRequestCT (Proxy :: Proxy ct) H.methodGet req [200, 203] host
130
137
131-- | If you have a 'Get xs ()' endpoint, the client expects a 204 No Content
138-- | If you have a 'Get xs ()' endpoint, the client expects a 204 No Content
132-- HTTP header.
139-- HTTP header.
140+instance
141+#if MIN_VERSION_base(4,8,0)
142+ {-# OVERLAPPING #-}
143+#endif
133−instance HasClient (Get (ct ': cts) ()) where
144+ HasClient (Get (ct ': cts) ()) where
134 type Client' (Get (ct ': cts) ()) = BaseUrl -> EitherT ServantError IO ()
145 type Client' (Get (ct ': cts) ()) = BaseUrl -> EitherT ServantError IO ()
135 clientWithRoute Proxy req host =
146 clientWithRoute Proxy req host =
136 performRequestNoBody H.methodGet req [204] host
147 performRequestNoBody H.methodGet req [204] host
@@ -176,7 +187,11 @@ instance (KnownSymbol sym, ToText a, HasClient sublayout)
176-- side querying function that is created when calling 'client'
187-- side querying function that is created when calling 'client'
177-- will just require an argument that specifies the scheme, host
188-- will just require an argument that specifies the scheme, host
178-- and port to send the request to.
189-- and port to send the request to.
190+instance
191+#if MIN_VERSION_base(4,8,0)
192+ {-# OVERLAPPABLE #-}
193+#endif
179−instance (MimeUnrender ct a) => HasClient (Post (ct ': cts) a) where
194+ (MimeUnrender ct a) => HasClient (Post (ct ': cts) a) where
180 type Client' (Post (ct ': cts) a) = BaseUrl -> EitherT ServantError IO a
195 type Client' (Post (ct ': cts) a) = BaseUrl -> EitherT ServantError IO a
181
196
182 clientWithRoute Proxy req uri =
197 clientWithRoute Proxy req uri =
@@ -184,7 +199,11 @@ instance (MimeUnrender ct a) => HasClient (Post (ct ': cts) a) where
184
199
185-- | If you have a 'Post xs ()' endpoint, the client expects a 204 No Content
200-- | If you have a 'Post xs ()' endpoint, the client expects a 204 No Content
186-- HTTP header.
201-- HTTP header.
202+instance
203+#if MIN_VERSION_base(4,8,0)
204+ {-# OVERLAPPING #-}
205+#endif
187−instance HasClient (Post (ct ': cts) ()) where
206+ HasClient (Post (ct ': cts) ()) where
188 type Client' (Post (ct ': cts) ()) = BaseUrl -> EitherT ServantError IO ()
207 type Client' (Post (ct ': cts) ()) = BaseUrl -> EitherT ServantError IO ()
189 clientWithRoute Proxy req host =
208 clientWithRoute Proxy req host =
190 void $ performRequestNoBody H.methodPost req [204] host
209 void $ performRequestNoBody H.methodPost req [204] host
@@ -193,7 +212,11 @@ instance HasClient (Post (ct ': cts) ()) where
193-- side querying function that is created when calling 'client'
212-- side querying function that is created when calling 'client'
194-- will just require an argument that specifies the scheme, host
213-- will just require an argument that specifies the scheme, host
195-- and port to send the request to.
214-- and port to send the request to.
215+instance
216+#if MIN_VERSION_base(4,8,0)
217+ {-# OVERLAPPABLE #-}
218+#endif
196−instance (MimeUnrender ct a) => HasClient (Put (ct ': cts) a) where
219+ (MimeUnrender ct a) => HasClient (Put (ct ': cts) a) where
197 type Client' (Put (ct ': cts) a) = BaseUrl -> EitherT ServantError IO a
220 type Client' (Put (ct ': cts) a) = BaseUrl -> EitherT ServantError IO a
198
221
199 clientWithRoute Proxy req host =
222 clientWithRoute Proxy req host =
@@ -201,7 +224,11 @@ instance (MimeUnrender ct a) => HasClient (Put (ct ': cts) a) where
201
224
202-- | If you have a 'Put xs ()' endpoint, the client expects a 204 No Content
225-- | If you have a 'Put xs ()' endpoint, the client expects a 204 No Content
203-- HTTP header.
226-- HTTP header.
227+instance
228+#if MIN_VERSION_base(4,8,0)
229+ {-# OVERLAPPING #-}
230+#endif
204−instance HasClient (Put (ct ': cts) ()) where
231+ HasClient (Put (ct ': cts) ()) where
205 type Client' (Put (ct ': cts) ()) = BaseUrl -> EitherT ServantError IO ()
232 type Client' (Put (ct ': cts) ()) = BaseUrl -> EitherT ServantError IO ()
206 clientWithRoute Proxy req host =
233 clientWithRoute Proxy req host =
207 void $ performRequestNoBody H.methodPut req [204] host
234 void $ performRequestNoBody H.methodPut req [204] host
@@ -210,7 +237,11 @@ instance HasClient (Put (ct ': cts) ()) where
210-- side querying function that is created when calling 'client'
237-- side querying function that is created when calling 'client'
211-- will just require an argument that specifies the scheme, host
238-- will just require an argument that specifies the scheme, host
212-- and port to send the request to.
239-- and port to send the request to.
240+instance
241+#if MIN_VERSION_base(4,8,0)
242+ {-# OVERLAPPABLE #-}
243+#endif
213−instance (MimeUnrender ct a) => HasClient (Patch (ct ': cts) a) where
244+ (MimeUnrender ct a) => HasClient (Patch (ct ': cts) a) where
214 type Client' (Patch (ct ': cts) a) = BaseUrl -> EitherT ServantError IO a
245 type Client' (Patch (ct ': cts) a) = BaseUrl -> EitherT ServantError IO a
215
246
216 clientWithRoute Proxy req host =
247 clientWithRoute Proxy req host =
@@ -218,7 +249,11 @@ instance (MimeUnrender ct a) => HasClient (Patch (ct ': cts) a) where
218
249
219-- | If you have a 'Patch xs ()' endpoint, the client expects a 204 No Content
250-- | If you have a 'Patch xs ()' endpoint, the client expects a 204 No Content
220-- HTTP header.
251-- HTTP header.
252+instance
253+#if MIN_VERSION_base(4,8,0)
254+ {-# OVERLAPPING #-}
255+#endif
221−instance HasClient (Patch (ct ': cts) ()) where
256+ HasClient (Patch (ct ': cts) ()) where
222 type Client' (Patch (ct ': cts) ()) = BaseUrl -> EitherT ServantError IO ()
257 type Client' (Patch (ct ': cts) ()) = BaseUrl -> EitherT ServantError IO ()
223 clientWithRoute Proxy req host =
258 clientWithRoute Proxy req host =
224 void $ performRequestNoBody H.methodPatch req [204] host
259 void $ performRequestNoBody H.methodPatch req [204] host
servant-client/src/Servant/Common/Req.hs+4−1
@@ -1,8 +1,11 @@
1+{-# LANGUAGE CPP #-}
1−{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE ScopedTypeVariables #-}
3{-# LANGUAGE ScopedTypeVariables #-}
3module Servant.Common.Req where
4module Servant.Common.Req where
4
5
6+#if !MIN_VERSION_base(4,8,0)
5import Control.Applicative
7import Control.Applicative
8+#endif
6import Control.Exception
9import Control.Exception
7import Control.Monad
10import Control.Monad
8import Control.Monad.Catch (MonadThrow)
11import Control.Monad.Catch (MonadThrow)
servant-client/test/Servant/ClientSpec.hs+1−1
@@ -340,6 +340,6 @@ pathGen :: Gen (NonEmptyList Char)
340pathGen = fmap NonEmpty path
340pathGen = fmap NonEmpty path
341 where
341 where
342 path = listOf1 $ elements $
342 path = listOf1 $ elements $
343− filter (not . (`elem` "?%[]/#;")) $
343+ filter (not . (`elem` ("?%[]/#;" :: String))) $
344 filter isPrint $
344 filter isPrint $
345 map chr [0..127]
345 map chr [0..127]
servant-client/test/Servant/Common/BaseUrlSpec.hs+3
@@ -1,7 +1,10 @@
1+{-# LANGUAGE CPP #-}
1{-# OPTIONS_GHC -fno-warn-orphans #-}
2{-# OPTIONS_GHC -fno-warn-orphans #-}
2module Servant.Common.BaseUrlSpec where
3module Servant.Common.BaseUrlSpec where
3
4
5+#if !MIN_VERSION_base(4,8,0)
4import Control.Applicative
6import Control.Applicative
7+#endif
5import Control.DeepSeq
8import Control.DeepSeq
6import Test.Hspec
9import Test.Hspec
7import Test.QuickCheck
10import Test.QuickCheck
servant-docs/src/Servant/Docs/Internal.hs+3
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
1{-# LANGUAGE ConstraintKinds #-}
2{-# LANGUAGE ConstraintKinds #-}
2{-# LANGUAGE DataKinds #-}
3{-# LANGUAGE DataKinds #-}
3{-# LANGUAGE DeriveGeneric #-}
4{-# LANGUAGE DeriveGeneric #-}
@@ -13,7 +14,9 @@
13{-# LANGUAGE UndecidableInstances #-}
14{-# LANGUAGE UndecidableInstances #-}
14module Servant.Docs.Internal where
15module Servant.Docs.Internal where
15
16
17+#if !MIN_VERSION_base(4,8,0)
16import Control.Applicative
18import Control.Applicative
19+#endif
17import Control.Lens
20import Control.Lens
18import Data.ByteString.Lazy.Char8 (ByteString)
21import Data.ByteString.Lazy.Char8 (ByteString)
19import Data.Hashable
22import Data.Hashable
servant-jquery/src/Servant/JQuery/Internal.hs+11−8
@@ -1,15 +1,18 @@
1−{-# LANGUAGE DataKinds #-}
1+{-# LANGUAGE CPP #-}
2−{-# LANGUAGE TypeFamilies #-}
2+{-# LANGUAGE ConstraintKinds #-}
3−{-# LANGUAGE TypeOperators #-}
3+{-# LANGUAGE DataKinds #-}
4−{-# LANGUAGE ConstraintKinds #-}
5−{-# LANGUAGE TemplateHaskell #-}
6−{-# LANGUAGE FlexibleContexts #-}
4+{-# LANGUAGE FlexibleContexts #-}
7−{-# LANGUAGE FlexibleInstances #-}
5+{-# LANGUAGE FlexibleInstances #-}
8−{-# LANGUAGE ScopedTypeVariables #-}
6+{-# LANGUAGE ScopedTypeVariables #-}
7+{-# LANGUAGE TemplateHaskell #-}
8+{-# LANGUAGE TypeFamilies #-}
9+{-# LANGUAGE TypeOperators #-}
9{-# LANGUAGE UndecidableInstances #-}
10{-# LANGUAGE UndecidableInstances #-}
10module Servant.JQuery.Internal where
11module Servant.JQuery.Internal where
11
12
13+#if !MIN_VERSION_base(4,8,0)
12import Control.Applicative
14import Control.Applicative
15+#endif
13import Control.Lens
16import Control.Lens
14import Data.Char (toLower)
17import Data.Char (toLower)
15import qualified Data.CharSet as Set
18import qualified Data.CharSet as Set
servant-server/src/Servant/Server/Internal.hs+81−16
@@ -1,12 +1,15 @@
1+{-# LANGUAGE CPP #-}
1{-# LANGUAGE DataKinds #-}
2{-# LANGUAGE DataKinds #-}
2{-# LANGUAGE FlexibleContexts #-}
3{-# LANGUAGE FlexibleContexts #-}
3{-# LANGUAGE FlexibleInstances #-}
4{-# LANGUAGE FlexibleInstances #-}
4−{-# LANGUAGE OverlappingInstances #-}
5{-# LANGUAGE OverloadedStrings #-}
5{-# LANGUAGE OverloadedStrings #-}
6{-# LANGUAGE PolyKinds #-}
6{-# LANGUAGE PolyKinds #-}
7{-# LANGUAGE ScopedTypeVariables #-}
7{-# LANGUAGE ScopedTypeVariables #-}
8{-# LANGUAGE TypeFamilies #-}
8{-# LANGUAGE TypeFamilies #-}
9{-# LANGUAGE TypeOperators #-}
9{-# LANGUAGE TypeOperators #-}
10+#if !MIN_VERSION_base(4,8,0)
11+{-# LANGUAGE OverlappingInstances #-}
12+#endif
10module Servant.Server.Internal where
13module Servant.Server.Internal where
11
14
12import Control.Applicative ((<$>))
15import Control.Applicative ((<$>))
@@ -280,8 +283,11 @@ instance HasServer Delete where
280-- (returning a status code of 200). If there was no @Accept@ header or it
283-- (returning a status code of 200). If there was no @Accept@ header or it
281-- was @*/*@, we return encode using the first @Content-Type@ type on the
284-- was @*/*@, we return encode using the first @Content-Type@ type on the
282-- list.
285-- list.
283−instance ( AllCTRender ctypes a
286+instance
287+#if MIN_VERSION_base(4,8,0)
288+ {-# OVERLAPPABLE #-}
289+#endif
284− ) => HasServer (Get ctypes a) where
290+ ( AllCTRender ctypes a ) => HasServer (Get ctypes a) where
285
291
286 type ServerT' (Get ctypes a) m = m a
292 type ServerT' (Get ctypes a) m = m a
287
293
@@ -302,8 +308,14 @@ instance ( AllCTRender ctypes a
302 | otherwise = respond $ failWith NotFound
308 | otherwise = respond $ failWith NotFound
303
309
304-- '()' ==> 204 No Content
310-- '()' ==> 204 No Content
311+instance
312+#if MIN_VERSION_base(4,8,0)
313+ {-# OVERLAPPING #-}
314+#endif
305−instance HasServer (Get ctypes ()) where
315+ HasServer (Get ctypes ()) where
316+
306 type ServerT' (Get ctypes ()) m = m ()
317 type ServerT' (Get ctypes ()) m = m ()
318+
307 route Proxy action request respond
319 route Proxy action request respond
308 | pathIsEmpty request && requestMethod request == methodGet = do
320 | pathIsEmpty request && requestMethod request == methodGet = do
309 e <- runEitherT action
321 e <- runEitherT action
@@ -316,8 +328,14 @@ instance HasServer (Get ctypes ()) where
316 | otherwise = respond $ failWith NotFound
328 | otherwise = respond $ failWith NotFound
317
329
318-- Add response headers
330-- Add response headers
331+instance
332+#if MIN_VERSION_base(4,8,0)
333+ {-# OVERLAPPING #-}
334+#endif
319−instance ( AllCTRender ctypes v ) => HasServer (Get ctypes (Headers h v)) where
335+ ( AllCTRender ctypes v ) => HasServer (Get ctypes (Headers h v)) where
336+
320 type ServerT' (Get ctypes (Headers h v)) m = m (Headers h v)
337 type ServerT' (Get ctypes (Headers h v)) m = m (Headers h v)
338+
321 route Proxy action request respond
339 route Proxy action request respond
322 | pathIsEmpty request && requestMethod request == methodGet = do
340 | pathIsEmpty request && requestMethod request == methodGet = do
323 e <- runEitherT action
341 e <- runEitherT action
@@ -380,7 +398,11 @@ instance (KnownSymbol sym, FromText a, HasServer sublayout)
380-- (returning a status code of 201). If there was no @Accept@ header or it
398-- (returning a status code of 201). If there was no @Accept@ header or it
381-- was @*/*@, we return encode using the first @Content-Type@ type on the
399-- was @*/*@, we return encode using the first @Content-Type@ type on the
382-- list.
400-- list.
401+instance
402+#if MIN_VERSION_base(4,8,0)
403+ {-# OVERLAPPABLE #-}
404+#endif
383−instance ( AllCTRender ctypes a
405+ ( AllCTRender ctypes a
384 ) => HasServer (Post ctypes a) where
406 ) => HasServer (Post ctypes a) where
385
407
386 type ServerT' (Post ctypes a) m = m a
408 type ServerT' (Post ctypes a) m = m a
@@ -401,8 +423,14 @@ instance ( AllCTRender ctypes a
401 respond $ failWith WrongMethod
423 respond $ failWith WrongMethod
402 | otherwise = respond $ failWith NotFound
424 | otherwise = respond $ failWith NotFound
403
425
426+instance
427+#if MIN_VERSION_base(4,8,0)
428+ {-# OVERLAPPING #-}
429+#endif
404−instance HasServer (Post ctypes ()) where
430+ HasServer (Post ctypes ()) where
431+
405 type ServerT' (Post ctypes ()) m = m ()
432 type ServerT' (Post ctypes ()) m = m ()
433+
406 route Proxy action request respond
434 route Proxy action request respond
407 | pathIsEmpty request && requestMethod request == methodPost = do
435 | pathIsEmpty request && requestMethod request == methodPost = do
408 e <- runEitherT action
436 e <- runEitherT action
@@ -415,8 +443,14 @@ instance HasServer (Post ctypes ()) where
415 | otherwise = respond $ failWith NotFound
443 | otherwise = respond $ failWith NotFound
416
444
417-- Add response headers
445-- Add response headers
446+instance
447+#if MIN_VERSION_base(4,8,0)
448+ {-# OVERLAPPING #-}
449+#endif
418−instance ( AllCTRender ctypes v ) => HasServer (Post ctypes (Headers h v)) where
450+ ( AllCTRender ctypes v ) => HasServer (Post ctypes (Headers h v)) where
451+
419 type ServerT' (Post ctypes (Headers h v)) m = m (Headers h v)
452 type ServerT' (Post ctypes (Headers h v)) m = m (Headers h v)
453+
420 route Proxy action request respond
454 route Proxy action request respond
421 | pathIsEmpty request && requestMethod request == methodPost = do
455 | pathIsEmpty request && requestMethod request == methodPost = do
422 e <- runEitherT action
456 e <- runEitherT action
@@ -447,8 +481,11 @@ instance ( AllCTRender ctypes v ) => HasServer (Post ctypes (Headers h v)) where
447-- (returning a status code of 200). If there was no @Accept@ header or it
481-- (returning a status code of 200). If there was no @Accept@ header or it
448-- was @*/*@, we return encode using the first @Content-Type@ type on the
482-- was @*/*@, we return encode using the first @Content-Type@ type on the
449-- list.
483-- list.
450−instance ( AllCTRender ctypes a
484+instance
485+#if MIN_VERSION_base(4,8,0)
486+ {-# OVERLAPPABLE #-}
487+#endif
451− ) => HasServer (Put ctypes a) where
488+ ( AllCTRender ctypes a) => HasServer (Put ctypes a) where
452
489
453 type ServerT' (Put ctypes a) m = m a
490 type ServerT' (Put ctypes a) m = m a
454
491
@@ -468,8 +505,14 @@ instance ( AllCTRender ctypes a
468 respond $ failWith WrongMethod
505 respond $ failWith WrongMethod
469 | otherwise = respond $ failWith NotFound
506 | otherwise = respond $ failWith NotFound
470
507
508+instance
509+#if MIN_VERSION_base(4,8,0)
510+ {-# OVERLAPPING #-}
511+#endif
471−instance HasServer (Put ctypes ()) where
512+ HasServer (Put ctypes ()) where
513+
472 type ServerT' (Put ctypes ()) m = m ()
514 type ServerT' (Put ctypes ()) m = m ()
515+
473 route Proxy action request respond
516 route Proxy action request respond
474 | pathIsEmpty request && requestMethod request == methodPut = do
517 | pathIsEmpty request && requestMethod request == methodPut = do
475 e <- runEitherT action
518 e <- runEitherT action
@@ -482,8 +525,14 @@ instance HasServer (Put ctypes ()) where
482 | otherwise = respond $ failWith NotFound
525 | otherwise = respond $ failWith NotFound
483
526
484-- Add response headers
527-- Add response headers
528+instance
529+#if MIN_VERSION_base(4,8,0)
530+ {-# OVERLAPPING #-}
531+#endif
485−instance ( AllCTRender ctypes v ) => HasServer (Put ctypes (Headers h v)) where
532+ ( AllCTRender ctypes v ) => HasServer (Put ctypes (Headers h v)) where
533+
486 type ServerT' (Put ctypes (Headers h v)) m = m (Headers h v)
534 type ServerT' (Put ctypes (Headers h v)) m = m (Headers h v)
535+
487 route Proxy action request respond
536 route Proxy action request respond
488 | pathIsEmpty request && requestMethod request == methodPut = do
537 | pathIsEmpty request && requestMethod request == methodPut = do
489 e <- runEitherT action
538 e <- runEitherT action
@@ -512,8 +561,12 @@ instance ( AllCTRender ctypes v ) => HasServer (Put ctypes (Headers h v)) where
512-- If successfully returning a value, we just require that its type has
561-- If successfully returning a value, we just require that its type has
513-- a 'ToJSON' instance and servant takes care of encoding it for you,
562-- a 'ToJSON' instance and servant takes care of encoding it for you,
514-- yielding status code 200 along the way.
563-- yielding status code 200 along the way.
515−instance ( AllCTRender ctypes a
564+instance
565+#if MIN_VERSION_base(4,8,0)
566+ {-# OVERLAPPABLE #-}
567+#endif
516− ) => HasServer (Patch ctypes a) where
568+ ( AllCTRender ctypes a) => HasServer (Patch ctypes a) where
569+
517 type ServerT' (Patch ctypes a) m = m a
570 type ServerT' (Patch ctypes a) m = m a
518
571
519 route Proxy action request respond
572 route Proxy action request respond
@@ -532,8 +585,14 @@ instance ( AllCTRender ctypes a
532 respond $ failWith WrongMethod
585 respond $ failWith WrongMethod
533 | otherwise = respond $ failWith NotFound
586 | otherwise = respond $ failWith NotFound
534
587
588+instance
589+#if MIN_VERSION_base(4,8,0)
590+ {-# OVERLAPPING #-}
591+#endif
535−instance HasServer (Patch ctypes ()) where
592+ HasServer (Patch ctypes ()) where
593+
536 type ServerT' (Patch ctypes ()) m = m ()
594 type ServerT' (Patch ctypes ()) m = m ()
595+
537 route Proxy action request respond
596 route Proxy action request respond
538 | pathIsEmpty request && requestMethod request == methodPatch = do
597 | pathIsEmpty request && requestMethod request == methodPatch = do
539 e <- runEitherT action
598 e <- runEitherT action
@@ -546,8 +605,14 @@ instance HasServer (Patch ctypes ()) where
546 | otherwise = respond $ failWith NotFound
605 | otherwise = respond $ failWith NotFound
547
606
548-- Add response headers
607-- Add response headers
608+instance
609+#if MIN_VERSION_base(4,8,0)
610+ {-# OVERLAPPING #-}
611+#endif
549−instance ( AllCTRender ctypes v ) => HasServer (Patch ctypes (Headers h v)) where
612+ ( AllCTRender ctypes v ) => HasServer (Patch ctypes (Headers h v)) where
613+
550 type ServerT' (Patch ctypes (Headers h v)) m = m (Headers h v)
614 type ServerT' (Patch ctypes (Headers h v)) m = m (Headers h v)
615+
551 route Proxy action request respond
616 route Proxy action request respond
552 | pathIsEmpty request && requestMethod request == methodPatch = do
617 | pathIsEmpty request && requestMethod request == methodPatch = do
553 e <- runEitherT action
618 e <- runEitherT action
servant/servant.cabal+2−1
@@ -59,7 +59,8 @@ library
59 , network-uri >= 2.6
59 , network-uri >= 2.6
60 hs-source-dirs: src
60 hs-source-dirs: src
61 default-language: Haskell2010
61 default-language: Haskell2010
62+ other-extensions: CPP
62− other-extensions: ConstraintKinds
63+ , ConstraintKinds
63 , DataKinds
64 , DataKinds
64 , DeriveDataTypeable
65 , DeriveDataTypeable
65 , FlexibleInstances
66 , FlexibleInstances
servant/src/Servant/API/Alternative.hs+3
@@ -1,8 +1,11 @@
1+{-# LANGUAGE CPP #-}
1{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE TypeOperators #-}
3{-# LANGUAGE TypeOperators #-}
3module Servant.API.Alternative ((:<|>)(..)) where
4module Servant.API.Alternative ((:<|>)(..)) where
4
5
6+#if !MIN_VERSION_base(4,8,0)
5import Data.Monoid (Monoid (..))
7import Data.Monoid (Monoid (..))
8+#endif
6import Data.Typeable (Typeable)
9import Data.Typeable (Typeable)
7-- | Union of two APIs, first takes precedence in case of overlap.
10-- | Union of two APIs, first takes precedence in case of overlap.
8--
11--
servant/src/Servant/API/ContentTypes.hs+3
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
1{-# LANGUAGE ConstraintKinds #-}
2{-# LANGUAGE ConstraintKinds #-}
2{-# LANGUAGE DataKinds #-}
3{-# LANGUAGE DataKinds #-}
3{-# LANGUAGE DeriveDataTypeable #-}
4{-# LANGUAGE DeriveDataTypeable #-}
@@ -63,7 +64,9 @@ module Servant.API.ContentTypes
63 , eitherDecodeLenient
64 , eitherDecodeLenient
64 ) where
65 ) where
65
66
67+#if !MIN_VERSION_base(4,8,0)
66import Control.Applicative ((<*))
68import Control.Applicative ((<*))
69+#endif
67import Control.Arrow (left)
70import Control.Arrow (left)
68import Control.Monad
71import Control.Monad
69import Data.Aeson (FromJSON, ToJSON, Value,
72import Data.Aeson (FromJSON, ToJSON, Value,
servant/src/Servant/API/ResponseHeaders.hs+14−3
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
1{-# LANGUAGE DataKinds #-}
2{-# LANGUAGE DataKinds #-}
2{-# LANGUAGE DeriveFunctor #-}
3{-# LANGUAGE DeriveFunctor #-}
3{-# LANGUAGE FlexibleContexts #-}
4{-# LANGUAGE FlexibleContexts #-}
@@ -6,11 +7,13 @@
6{-# LANGUAGE GADTs #-}
7{-# LANGUAGE GADTs #-}
7{-# LANGUAGE KindSignatures #-}
8{-# LANGUAGE KindSignatures #-}
8{-# LANGUAGE MultiParamTypeClasses #-}
9{-# LANGUAGE MultiParamTypeClasses #-}
9−{-# LANGUAGE OverlappingInstances #-}
10{-# LANGUAGE PolyKinds #-}
10{-# LANGUAGE PolyKinds #-}
11{-# LANGUAGE ScopedTypeVariables #-}
11{-# LANGUAGE ScopedTypeVariables #-}
12{-# LANGUAGE TypeOperators #-}
12{-# LANGUAGE TypeOperators #-}
13{-# LANGUAGE UndecidableInstances #-}
13{-# LANGUAGE UndecidableInstances #-}
14+#if !MIN_VERSION_base(4,8,0)
15+{-# LANGUAGE OverlappingInstances #-}
16+#endif
14
17
15-- | This module provides facilities for adding headers to a response.
18-- | This module provides facilities for adding headers to a response.
16--
19--
@@ -50,13 +53,21 @@ class AddHeader h v orig new
50 | h v orig -> new, new -> h, new -> v, new -> orig where
53 | h v orig -> new, new -> h, new -> v, new -> orig where
51 addHeader :: v -> orig -> new
54 addHeader :: v -> orig -> new
52
55
56+instance
57+#if MIN_VERSION_base(4,8,0)
58+ {-# OVERLAPPING #-}
59+#endif
53−instance ( KnownSymbol h, ToByteString v
60+ ( KnownSymbol h, ToByteString v
54 ) => AddHeader h v (Headers (fst ': rest) a) (Headers (Header h v ': fst ': rest) a) where
61 ) => AddHeader h v (Headers (fst ': rest) a) (Headers (Header h v ': fst ': rest) a) where
55 addHeader a (Headers resp heads) = Headers resp ((headerName, toByteString' a) : heads)
62 addHeader a (Headers resp heads) = Headers resp ((headerName, toByteString' a) : heads)
56 where
63 where
57 headerName = CI.mk . pack $ symbolVal (Proxy :: Proxy h)
64 headerName = CI.mk . pack $ symbolVal (Proxy :: Proxy h)
58
65
66+instance
67+#if MIN_VERSION_base(4,8,0)
68+ {-# OVERLAPPABLE #-}
69+#endif
59−instance ( KnownSymbol h, ToByteString v
70+ ( KnownSymbol h, ToByteString v
60 , new ~ (Headers '[Header h v] a)
71 , new ~ (Headers '[Header h v] a)
61 ) => AddHeader h v a new where
72 ) => AddHeader h v a new where
62 addHeader a resp = Headers resp [(headerName, toByteString' a)]
73 addHeader a resp = Headers resp [(headerName, toByteString' a)]
servant/src/Servant/Common/Text.hs+8−1
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
1{-# LANGUAGE FlexibleInstances #-}
2{-# LANGUAGE FlexibleInstances #-}
2{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE TypeSynonymInstances #-}
4{-# LANGUAGE TypeSynonymInstances #-}
@@ -6,12 +7,18 @@ module Servant.Common.Text
6 , ToText(..)
7 , ToText(..)
7 ) where
8 ) where
8
9
10+#if !MIN_VERSION_base(4,8,0)
9import Control.Applicative ((<$>))
11import Control.Applicative ((<$>))
12+#endif
10import Data.Int (Int16, Int32, Int64, Int8)
13import Data.Int (Int16, Int32, Int64, Int8)
11import Data.String.Conversions (cs)
14import Data.String.Conversions (cs)
12import Data.Text (Text)
15import Data.Text (Text)
13import Data.Text.Read (Reader, decimal, rational, signed)
16import 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+ )
15
22
16-- | For getting values from url captures and query string parameters
23-- | For getting values from url captures and query string parameters
17-- Instances should obey:
24-- Instances should obey:
servant/src/Servant/Utils/Links.hs+13−9
@@ -1,13 +1,13 @@
1−{-# LANGUAGE PolyKinds #-}
1+{-# LANGUAGE CPP #-}
2−{-# LANGUAGE ConstraintKinds #-}
2+{-# LANGUAGE ConstraintKinds #-}
3−{-# LANGUAGE DataKinds #-}
3+{-# LANGUAGE DataKinds #-}
4−{-# LANGUAGE FlexibleInstances #-}
4+{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE FunctionalDependencies #-}
5{-# LANGUAGE FunctionalDependencies #-}
6−{-# LANGUAGE PolyKinds #-}
6+{-# LANGUAGE PolyKinds #-}
7−{-# LANGUAGE ScopedTypeVariables #-}
7+{-# LANGUAGE ScopedTypeVariables #-}
8−{-# LANGUAGE TypeFamilies #-}
8+{-# LANGUAGE TypeFamilies #-}
9−{-# LANGUAGE TypeOperators #-}
9+{-# LANGUAGE TypeOperators #-}
10−{-# LANGUAGE UndecidableInstances #-}
10+{-# LANGUAGE UndecidableInstances #-}
11
11
12-- | Type safe generation of internal links.
12-- | Type safe generation of internal links.
13--
13--
@@ -104,7 +104,11 @@ module Servant.Utils.Links (
104import Data.List
104import Data.List
105import Data.Proxy ( Proxy(..) )
105import Data.Proxy ( Proxy(..) )
106import Data.Text (Text, unpack)
106import Data.Text (Text, unpack)
107+#if !MIN_VERSION_base(4,8,0)
107import Data.Monoid ( Monoid(..), (<>) )
108import Data.Monoid ( Monoid(..), (<>) )
109+#else
110+import Data.Monoid ( (<>) )
111+#endif
108import Network.URI ( URI(..), escapeURIString, isUnreserved )
112import Network.URI ( URI(..), escapeURIString, isUnreserved )
109import GHC.TypeLits ( KnownSymbol, symbolVal )
113import GHC.TypeLits ( KnownSymbol, symbolVal )
110import GHC.Exts(Constraint)
114import GHC.Exts(Constraint)
servant/test/Servant/API/ContentTypesSpec.hs+3
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
1{-# LANGUAGE DataKinds #-}
2{-# LANGUAGE DataKinds #-}
2{-# LANGUAGE DeriveGeneric #-}
3{-# LANGUAGE DeriveGeneric #-}
3{-# LANGUAGE MultiParamTypeClasses #-}
4{-# LANGUAGE MultiParamTypeClasses #-}
@@ -5,7 +6,9 @@
5{-# OPTIONS_GHC -fno-warn-orphans #-}
6{-# OPTIONS_GHC -fno-warn-orphans #-}
6module Servant.API.ContentTypesSpec where
7module Servant.API.ContentTypesSpec where
7
8
9+#if !MIN_VERSION_base(4,8,0)
8import Control.Applicative
10import Control.Applicative
11+#endif
9import Control.Arrow
12import Control.Arrow
10import Data.Aeson
13import Data.Aeson
11import Data.Aeson.Parser (jstring)
14import Data.Aeson.Parser (jstring)
servant/test/Servant/Common/TextSpec.hs+6−1
@@ -1,8 +1,13 @@
1+{-# LANGUAGE CPP #-}
1module Servant.Common.TextSpec where
2module Servant.Common.TextSpec where
2
3
3import Data.Int (Int16, Int32, Int64, Int8)
4import Data.Int (Int16, Int32, Int64, Int8)
4import Data.Text (Text)
5import 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+ )
6import Servant.Common.Text
11import Servant.Common.Text
7import Test.Hspec
12import Test.Hspec
8import Test.QuickCheck
13import Test.QuickCheck