git.iko.soy/typeable/servant
on master help sign in
Merge pull request #50 from haskell-servant/jkarni/sundry-cleanup

Sundry cleanup

commit6651df574ab76f78a0149cf9daa2930d2463270b authorJulian Arni <jkarni@gmail.com> dateWed 22 Apr 2015, 18:10 (11 years ago) parente9f73b07cb2ca0
35 files changed+449−162
.travis.yml+12−4 servant/README.md → README.md+5−5 scripts/shell.nix+20 scripts/test-all.sh+14−10 scripts/update-defaults-nix.sh+24 servant-client/README.md+1−4 servant-client/default.nix+24 servant-client/servant-client.cabal+4−2 servant-client/src/Servant/Client.hs+66−31 servant-client/src/Servant/Common/Req.hs+4−1 servant-client/test/Servant/ClientSpec.hs+5−2 servant-client/test/Servant/Common/BaseUrlSpec.hs+3 servant-docs/README.md+1−3 servant-docs/default.nix+1−1 servant-docs/servant-docs.cabal+4−2 servant-docs/src/Servant/Docs/Internal.hs+3 servant-jquery/README.md+3−6 servant-jquery/default.nix+21 servant-jquery/servant-jquery.cabal+7−4 servant-jquery/src/Servant/JQuery/Internal.hs+11−8 servant-server/README.md+4−7 servant-server/default.nix+26−13 servant-server/servant-server.cabal+8−4 servant-server/src/Servant/Server/Internal.hs+99−28 servant/servant.png → servant.png servant/default.nix+20−10 servant/servant.cabal+4−3 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 sources.txt+5
.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
servant/README.md → README.mdrenamed+5−5
@@ -21,8 +21,8 @@ We've written a [Getting Started](http://haskell-servant.github.io/getting-start
2121
2222## Repositories and Haddocks
2323
24−- The core [servant](http://github.com/haskell-servant) package - [docs](http://hackage.haskell.org/package/servant)
25−- Implementing an HTTP server for a webservice API with [servant-server](http://github.com/haskell-servant/servant-server) - [docs](http://hackage.haskell.org/package/servant-server)
26−- (Haskell) client-side function generation with [servant-client](http://github.com/haskell-servant/servant-client) - [docs](http://hackage.haskell.org/package/servant-client)
27−- (Javascript) client-side function generation with [servant-jquery](http://github.com/haskell-servant/servant-jquery) - [docs](http://hackage.haskell.org/package/servant-jquery)
28−- API docs generation with [servant-docs](http://github.com/haskell-servant/servant-docs) - [docs](http://hackage.haskell.org/package/servant-docs)
24+- The core [servant](http://github.com/haskell-servant/tree/master/servant) package - [docs](http://hackage.haskell.org/package/servant)
25+- Implementing an HTTP server for a webservice API with [servant-server](http://github.com/haskell-servant/servant/tree/master/servant-server) - [docs](http://hackage.haskell.org/package/servant-server)
26+- (Haskell) client-side function generation with [servant-client](http://github.com/haskell-servant/servant/tree/master/servant-client) - [docs](http://hackage.haskell.org/package/servant-client)
27+- (Javascript) client-side function generation with [servant-jquery](http://github.com/haskell-servant/servant/tree/master/servant-jquery) - [docs](http://hackage.haskell.org/package/servant-jquery)
28+- API docs generation with [servant-docs](http://github.com/haskell-servant/servant/tree/master/servant-docs) - [docs](http://hackage.haskell.org/package/servant-docs)
scripts/shell.nixnew file+20
@@ -0,0 +1,20 @@
1+# Get a Nix shell with all the packages installed
2+# Also a good way of running the tests for all packages
3+with (import <nixpkgs> {}).pkgs;
4+let modifiedHaskellPackages = haskellngPackages.override {
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";
16+ };
17+ };
18+in modifiedHaskellPackages.ghcWithPackages ( p : with p ; [
19+ servant servant-server servant-client servant-jquery servant-docs
20+])
scripts/test-all.sh+14−10
@@ -8,21 +8,25 @@
88# DESCRIPTION: Run tests for all source directories listed in $SOURCES.
99# Uses local versions of those sources.
1010#
11+# REQUIREMENTS: bash >= 4
1112#===============================================================================
1213
1314set -o nounset
1415set -o errexit
1516
16−SOURCES=( servant servant-server servant-client servant-jquery servant-docs )
17+DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
1718GHC_FLAGS="-Werror"
19+SOURCES_TXT="$( dirname $DIR)/sources.txt"
20+CABAL=${CABAL:-cabal}
21+
22+declare -a SOURCES
23+readarray -t SOURCES < "$SOURCES_TXT"
24+
1825
1926prepare_sandbox () {
20− cabal sandbox init
27+ $CABAL sandbox init
2128 for s in ${SOURCES[@]} ; do
22− cd "$s"
23− cabal sandbox init --sandbox=../
24− cabal sandbox add-source .
25− cd ..
29+ (cd "$s" && $CABAL sandbox init --sandbox=../ && $CABAL sandbox add-source .)
2630 done
2731}
2832
@@ -30,10 +34,10 @@ test_each () {
3034 for s in ${SOURCES[@]} ; do
3135 echo "Testing $s..."
3236 cd "$s"
33− cabal install --only-dependencies --enable-tests
34− cabal configure --enable-tests --ghc-options="$GHC_FLAGS"
35− cabal build
36− cabal test
37+ $CABAL install --only-dependencies --enable-tests
38+ $CABAL configure --enable-tests --ghc-options="$GHC_FLAGS"
39+ $CABAL build
40+ $CABAL test
3741 cd ..
3842 done
3943}
scripts/update-defaults-nix.shnew file+24
@@ -0,0 +1,24 @@
1+#!/bin/bash -
2+#===============================================================================
3+#
4+# USAGE: ./update-defaults-nix.sh
5+#
6+# DESCRIPTION: Updates the default.nix files in all source dirs
7+#
8+# REQUIREMENTS: cabal2nix, bash >= 4
9+#===============================================================================
10+
11+set -o nounset
12+set -o errexit
13+
14+DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
15+BASE_DIR="$( dirname $DIR)"
16+SOURCES_TXT="$BASE_DIR/sources.txt"
17+
18+declare -a SOURCES
19+readarray -t SOURCES < "$SOURCES_TXT"
20+
21+for s in ${SOURCES[@]} ; do
22+ echo $s
23+ (cd "$BASE_DIR/$s" && cabal2nix . > default.nix )
24+done
servant-client/README.md+1−4
@@ -1,8 +1,5 @@
11# servant-client
22
3−[![Build Status](https://secure.travis-ci.org/haskell-servant/servant-client.svg)](http://travis-ci.org/haskell-servant/servant-client)
4−[![Coverage Status](https://coveralls.io/repos/haskell-servant/servant-client/badge.svg)](https://coveralls.io/r/haskell-servant/servant-client)
5−
63![servant](https://raw.githubusercontent.com/haskell-servant/servant/master/servant.png)
74
85This library lets you automatically derive Haskell functions that let you query each endpoint of a *servant* webservice.
@@ -20,4 +17,4 @@ getAllBooks :: BaseUrl -> EitherT String IO [Book]
2017postNewBook :: Book -> BaseUrl -> EitherT String IO Book
2118-- 'client' allows you to produce operations to query an API from a client.
2219(getAllBooks :<|> postNewBook) = client myApi
23−```
20+```
servant-client/default.nixnew file+24
@@ -0,0 +1,24 @@
1+{ mkDerivation, aeson, attoparsec, base, bytestring, deepseq
2+, either, exceptions, hspec, http-client, http-client-tls
3+, http-media, http-types, HUnit, network, network-uri, QuickCheck
4+, safe, servant, servant-server, stdenv, string-conversions, text
5+, transformers, wai, warp
6+}:
7+mkDerivation {
8+ pname = "servant-client";
9+ version = "0.2.2";
10+ src = ./.;
11+ buildDepends = [
12+ aeson attoparsec base bytestring either exceptions http-client
13+ http-client-tls http-media http-types network-uri safe servant
14+ string-conversions text transformers
15+ ];
16+ testDepends = [
17+ aeson base bytestring deepseq either hspec http-client http-media
18+ http-types HUnit network QuickCheck servant servant-server text wai
19+ warp
20+ ];
21+ homepage = "http://haskell-servant.github.io/";
22+ description = "automatical derivation of querying functions for servant webservices";
23+ license = stdenv.lib.licenses.bsd3;
24+}
servant-client/servant-client.cabal+4−2
@@ -16,6 +16,8 @@ description:
1616 > getAllBooks :: BaseUrl -> EitherT String IO [Book]
1717 > postNewBook :: Book -> BaseUrl -> EitherT String IO Book
1818 > (getAllBooks :<|> postNewBook) = client myApi
19+ .
20+ <https://github.com/haskell-servant/servant/blob/master/servant-client/CHANGELOG.md CHANGELOG>
1921license: BSD3
2022license-file: LICENSE
2123author: Alp Mestanogullari, Sönke Hahn, Julian K. Arni
@@ -26,10 +28,10 @@ build-type: Simple
2628cabal-version: >=1.10
2729tested-with: GHC >= 7.8
2830homepage: http://haskell-servant.github.io/
29−Bug-reports: http://github.com/haskell-servant/servant-client/issues
31+Bug-reports: http://github.com/haskell-servant/servant/issues
3032source-repository head
3133 type: git
32− location: http://github.com/haskell-servant/servant-client.git
34+ location: http://github.com/haskell-servant/servant.git
3335
3436library
3537 exposed-modules:
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+5−2
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE DataKinds #-}
23{-# LANGUAGE DeriveGeneric #-}
34{-# LANGUAGE FlexibleContexts #-}
@@ -10,7 +11,9 @@
1011{-# OPTIONS_GHC -fno-warn-orphans #-}
1112module Servant.ClientSpec where
1213
13−import Control.Applicative
14+#if !MIN_VERSION_base(4,8,0)
15+import Control.Applicative ((<$>))
16+#endif
1417import qualified Control.Arrow as Arrow
1518import Control.Concurrent
1619import Control.Exception
@@ -340,6 +343,6 @@ pathGen :: Gen (NonEmptyList Char)
340343pathGen = fmap NonEmpty path
341344 where
342345 path = listOf1 $ elements $
343− filter (not . (`elem` "?%[]/#;")) $
346+ filter (not . (`elem` ("?%[]/#;" :: String))) $
344347 filter isPrint $
345348 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/README.md+1−3
@@ -1,14 +1,12 @@
11# servant-docs
22
3−[![Build Status](https://secure.travis-ci.org/haskell-servant/servant-docs.svg)](http://travis-ci.org/haskell-servant/servant-docs)
4−
53![servant](https://raw.githubusercontent.com/haskell-servant/servant/master/servant.png)
64
75Generate API docs for your *servant* webservice. Feel free to also take a look at [servant-pandoc](https://github.com/mpickering/servant-pandoc) which uses this package to target a broad range of output formats using the excellent **pandoc**.
86
97## Example
108
11−See [here](https://github.com/haskell-servant/servant-docs/blob/master/example/greet.md) for the output of the following program.
9+See [here](https://github.com/haskell-servant/servant/tree/master/servant-docs/blob/master/example/greet.md) for the output of the following program.
1210
1311``` haskell
1412{-# LANGUAGE DataKinds #-}
servant-docs/default.nix+1−1
@@ -12,7 +12,7 @@ mkDerivation {
1212 aeson base bytestring hashable http-media lens servant
1313 string-conversions text unordered-containers
1414 ];
15− testDepends = [ aeson base hspec lens servant ];
15+ testDepends = [ aeson base hspec servant string-conversions ];
1616 homepage = "http://haskell-servant.github.io/";
1717 description = "generate API docs for your servant webservice";
1818 license = stdenv.lib.licenses.bsd3;
servant-docs/servant-docs.cabal+4−2
@@ -5,6 +5,8 @@ description:
55 Library for generating API docs from a servant API definition.
66 .
77 Runnable example <https://github.com/haskell-servant/servant-docs/blob/master/example/greet.hs here>.
8+ .
9+ <https://github.com/haskell-servant/servant/blob/master/servant-docs/CHANGELOG.md CHANGELOG>
810license: BSD3
911license-file: LICENSE
1012author: Alp Mestanogullari, Sönke Hahn, Julian K. Arni
@@ -15,13 +17,13 @@ build-type: Simple
1517cabal-version: >=1.10
1618tested-with: GHC >= 7.8
1719homepage: http://haskell-servant.github.io/
18−Bug-reports: http://github.com/haskell-servant/servant-docs/issues
20+Bug-reports: http://github.com/haskell-servant/servant/issues
1921extra-source-files:
2022 CHANGELOG.md
2123 README.md
2224source-repository head
2325 type: git
24− location: http://github.com/haskell-servant/servant-docs.git
26+ location: http://github.com/haskell-servant/servant.git
2527
2628library
2729 exposed-modules:
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/README.md+3−6
@@ -1,15 +1,12 @@
11# servant-jquery
22
3−[![Build Status](https://secure.travis-ci.org/haskell-servant/servant-jquery.svg)](http://travis-ci.org/haskell-servant/servant-jquery)
4−[![Coverage Status](https://coveralls.io/repos/haskell-servant/servant-jquery/badge.svg)](https://coveralls.io/r/haskell-servant/servant-jquery)
5−
63![servant](https://raw.githubusercontent.com/haskell-servant/servant/master/servant.png)
74
85This library lets you derive automatically (JQuery based) Javascript functions that let you query each endpoint of a *servant* webservice.
96
107## Example
118
12−Read more about the following example [here](https://github.com/haskell-servant/servant-jquery/tree/master/examples#examples).
9+Read more about the following example [here](https://github.com/haskell-servant/servant/tree/master/servant-jquery/tree/master/examples#examples).
1310
1411``` haskell
1512{-# LANGUAGE DataKinds #-}
@@ -53,7 +50,7 @@ currentValue counter = liftIO $ readTVarIO counter
5350-- * Our API type
5451type TestApi = "counter" :> Post Counter -- endpoint for increasing the counter
5552 :<|> "counter" :> Get Counter -- endpoint to get the current value
56− :<|> Raw -- used for serving static files
53+ :<|> Raw -- used for serving static files
5754
5855testApi :: Proxy TestApi
5956testApi = Proxy
@@ -94,4 +91,4 @@ main = do
9491
9592 -- listen to requests on port 8080
9693 runServer cnt 8080
97−```
94+```
servant-jquery/default.nixnew file+21
@@ -0,0 +1,21 @@
1+{ mkDerivation, aeson, base, charset, filepath, hspec
2+, hspec-expectations, language-ecmascript, lens, servant
3+, servant-server, stdenv, stm, text, transformers, warp
4+}:
5+mkDerivation {
6+ pname = "servant-jquery";
7+ version = "0.2.2";
8+ src = ./.;
9+ isLibrary = true;
10+ isExecutable = true;
11+ buildDepends = [
12+ aeson base charset filepath lens servant servant-server stm text
13+ transformers warp
14+ ];
15+ testDepends = [
16+ base hspec hspec-expectations language-ecmascript lens servant
17+ ];
18+ homepage = "http://haskell-servant.github.io/";
19+ description = "Automatically derive (jquery) javascript functions to query servant webservices";
20+ license = stdenv.lib.licenses.bsd3;
21+}
servant-jquery/servant-jquery.cabal+7−4
@@ -4,8 +4,11 @@ synopsis: Automatically derive (jquery) javascript functions to query
44description:
55 Automatically derive jquery-based javascript functions to query servant webservices.
66 .
7− Example <https://github.com/haskell-servant/servant-jquery/blob/master/examples/counter.hs here> that serves the generated javascript to a webpage that lets you
8− trigger webservice calls.
7+ You can find an example <https://github.com/haskell-servant/servant/blob/master/servant-jquery/examples/counter.hs here>
8+ which serves the generated javascript to a webpage that allows you to trigger
9+ webservice calls.
10+ .
11+ <https://github.com/haskell-servant/servant/blob/master/servant-jquery/CHANGELOG.md CHANGELOG>
912license: BSD3
1013license-file: LICENSE
1114author: Alp Mestanogullari
@@ -15,13 +18,13 @@ category: Web
1518build-type: Simple
1619cabal-version: >=1.10
1720homepage: http://haskell-servant.github.io/
18−Bug-reports: http://github.com/haskell-servant/servant-jquery/issues
21+Bug-reports: http://github.com/haskell-servant/servant/issues
1922extra-source-files:
2023 CHANGELOG.md
2124 README.md
2225source-repository head
2326 type: git
24− location: http://github.com/haskell-servant/servant-jquery.git
27+ location: http://github.com/haskell-servant/servant.git
2528
2629flag example
2730 description: Build the example too
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/README.md+4−7
@@ -1,8 +1,5 @@
11# servant-server
22
3−[![Build Status](https://secure.travis-ci.org/haskell-servant/servant-server.svg)](http://travis-ci.org/haskell-servant/servant-server)
4−[![Coverage Status](https://coveralls.io/repos/haskell-servant/servant-server/badge.svg)](https://coveralls.io/r/haskell-servant/servant-server)
5−
63![servant](https://raw.githubusercontent.com/haskell-servant/servant/master/servant.png)
74
85This library lets you *implement* an HTTP server with handlers for each endpoint of a servant API, handling most of the boilerplate for you.
@@ -14,7 +11,7 @@ We've written a [Getting Started](http://haskell-servant.github.io/getting-start
1411## Repositories and Haddocks
1512
1613- The core [servant](http://github.com/haskell-servant) package - [docs](http://hackage.haskell.org/package/servant)
17−- Implementing an HTTP server for a webservice API with [servant-server](http://github.com/haskell-servant/servant-server) - [docs](http://hackage.haskell.org/package/servant-server)
18−- (Haskell) client-side function generation with [servant-client](http://github.com/haskell-servant/servant-client) - [docs](http://hackage.haskell.org/package/servant-client)
19−- (Javascript) client-side function generation with [servant-jquery](http://github.com/haskell-servant/servant-jquery) - [docs](http://hackage.haskell.org/package/servant-jquery)
20−- API docs generation with [servant-docs](http://github.com/haskell-servant/servant-docs) - [docs](http://hackage.haskell.org/package/servant-docs)
14+- Implementing an HTTP server for a webservice API with [servant-server](http://github.com/haskell-servant/servant/tree/master/servant-server) - [docs](http://hackage.haskell.org/package/servant-server)
15+- (Haskell) client-side function generation with [servant-client](http://github.com/haskell-servant/servant/tree/master/servant-client) - [docs](http://hackage.haskell.org/package/servant-client)
16+- (Javascript) client-side function generation with [servant-jquery](http://github.com/haskell-servant/servant/tree/master/servant-jquery) - [docs](http://hackage.haskell.org/package/servant-jquery)
17+- API docs generation with [servant-docs](http://github.com/haskell-servant/servant/tree/master/servant-docs) - [docs](http://hackage.haskell.org/package/servant-docs)
servant-server/default.nix+26−13
@@ -1,15 +1,28 @@
1−{ pkgs ? import <nixpkgs> { config.allowUnfree = true; }
2−, src ? builtins.filterSource (path: type:
3− type != "unknown" &&
4− baseNameOf path != ".git" &&
5− baseNameOf path != "result" &&
6− baseNameOf path != "dist") ./.
7−, servant ? import ../servant {}
1+{ mkDerivation, aeson, attoparsec, base, bytestring
2+, bytestring-conversion, directory, either, exceptions, hspec
3+, hspec-wai, http-types, network, network-uri, parsec, QuickCheck
4+, safe, servant, split, stdenv, string-conversions, system-filepath
5+, temporary, text, transformers, wai, wai-app-static, wai-extra
6+, warp
87}:
9−pkgs.haskellPackages.buildLocalCabalWithArgs {
10− name = "servant-server";
11− inherit src;
12− args = {
13− inherit servant;
14− };
8+mkDerivation {
9+ pname = "servant-server";
10+ version = "0.2.4";
11+ src = ./.;
12+ isLibrary = true;
13+ isExecutable = true;
14+ buildDepends = [
15+ aeson attoparsec base bytestring either http-types network-uri safe
16+ servant split string-conversions system-filepath text transformers
17+ wai wai-app-static warp
18+ ];
19+ testDepends = [
20+ aeson base bytestring bytestring-conversion directory either
21+ exceptions hspec hspec-wai http-types network parsec QuickCheck
22+ servant string-conversions temporary text transformers wai
23+ wai-extra warp
24+ ];
25+ homepage = "http://haskell-servant.github.io/";
26+ description = "A family of combinators for defining webservices APIs and serving them";
27+ license = stdenv.lib.licenses.bsd3;
1528}
servant-server/servant-server.cabal+8−4
@@ -4,12 +4,16 @@ synopsis: A family of combinators for defining webservices APIs and s
44description:
55 A family of combinators for defining webservices APIs and serving them
66 .
7− You can learn about the basics in <http://haskell-servant.github.io/getting-started/ the getting started> guide.
7+ You can learn about the basics in <http://haskell-servant.github.io/getting-started/ the getting started>
8+ guide.
89 .
9− <https://github.com/haskell-servant/servant-server/blob/master/example/greet.hs Here>'s a runnable example, with comments, that defines a dummy API and
10− implements a webserver that serves this API, using this package.
10+ <https://github.com/haskell-servant/servant/blob/master/servant-server/example/greet.hs Here>
11+ is a runnable example, with comments, that defines a dummy API and implements
12+ a webserver that serves this API, using this package.
13+ .
14+ <https://github.com/haskell-servant/servant/blob/master/servant-server/CHANGELOG.md CHANGELOG>
1115homepage: http://haskell-servant.github.io/
12−Bug-reports: http://github.com/haskell-servant/servant-server/issues
16+Bug-reports: http://github.com/haskell-servant/servant/issues
1317license: BSD3
1418license-file: LICENSE
1519author: Alp Mestanogullari, Sönke Hahn, Julian K. Arni
servant-server/src/Servant/Server/Internal.hs+99−28
@@ -1,22 +1,28 @@
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
13+
1014module Servant.Server.Internal where
1115
16+#if !MIN_VERSION_base(4,8,0)
1217import Control.Applicative ((<$>))
18+import Data.Monoid (Monoid, mappend, mempty)
19+#endif
1320import Control.Monad.Trans.Either (EitherT, runEitherT)
1421import qualified Data.ByteString as B
1522import qualified Data.ByteString.Lazy as BL
1623import Data.IORef (newIORef, readIORef, writeIORef)
1724import Data.List (unfoldr)
1825import Data.Maybe (catMaybes, fromMaybe)
19−import Data.Monoid (Monoid, mappend, mempty)
2026import Data.String (fromString)
2127import Data.String.Conversions (cs, (<>))
2228import Data.Text (Text)
@@ -278,10 +284,13 @@ instance HasServer Delete where
278284-- If successfully returning a value, we use the type-level list, combined
279285-- with the request's @Accept@ header, to encode the value for you
280286-- (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
287+-- was @*\/\*@, we return encode using the first @Content-Type@ type on the
282288-- list.
283−instance ( AllCTRender ctypes a
284− ) => HasServer (Get ctypes a) where
289+instance
290+#if MIN_VERSION_base(4,8,0)
291+ {-# OVERLAPPABLE #-}
292+#endif
293+ ( AllCTRender ctypes a ) => HasServer (Get ctypes a) where
285294
286295 type ServerT' (Get ctypes a) m = m a
287296
@@ -290,7 +299,7 @@ instance ( AllCTRender ctypes a
290299 e <- runEitherT action
291300 respond $ case e of
292301 Right output -> do
293− let accH = fromMaybe "*/*" $ lookup hAccept $ requestHeaders request
302+ let accH = fromMaybe ct_wildcard $ lookup hAccept $ requestHeaders request
294303 case handleAcceptH (Proxy :: Proxy ctypes) (AcceptHeader accH) output of
295304 Nothing -> failWith UnsupportedMediaType
296305 Just (contentT, body) -> succeedWith $
@@ -302,8 +311,14 @@ instance ( AllCTRender ctypes a
302311 | otherwise = respond $ failWith NotFound
303312
304313-- '()' ==> 204 No Content
305−instance HasServer (Get ctypes ()) where
314+instance
315+#if MIN_VERSION_base(4,8,0)
316+ {-# OVERLAPPING #-}
317+#endif
318+ HasServer (Get ctypes ()) where
319+
306320 type ServerT' (Get ctypes ()) m = m ()
321+
307322 route Proxy action request respond
308323 | pathIsEmpty request && requestMethod request == methodGet = do
309324 e <- runEitherT action
@@ -316,14 +331,20 @@ instance HasServer (Get ctypes ()) where
316331 | otherwise = respond $ failWith NotFound
317332
318333-- Add response headers
319−instance ( AllCTRender ctypes v ) => HasServer (Get ctypes (Headers h v)) where
334+instance
335+#if MIN_VERSION_base(4,8,0)
336+ {-# OVERLAPPING #-}
337+#endif
338+ ( AllCTRender ctypes v ) => HasServer (Get ctypes (Headers h v)) where
339+
320340 type ServerT' (Get ctypes (Headers h v)) m = m (Headers h v)
341+
321342 route Proxy action request respond
322343 | pathIsEmpty request && requestMethod request == methodGet = do
323344 e <- runEitherT action
324345 respond $ case e of
325346 Right output -> do
326− let accH = fromMaybe "*/*" $ lookup hAccept $ requestHeaders request
347+ let accH = fromMaybe ct_wildcard $ lookup hAccept $ requestHeaders request
327348 headers = getHeaders output
328349 case handleAcceptH (Proxy :: Proxy ctypes) (AcceptHeader accH) (getResponse output) of
329350 Nothing -> failWith UnsupportedMediaType
@@ -378,9 +399,13 @@ instance (KnownSymbol sym, FromText a, HasServer sublayout)
378399-- If successfully returning a value, we use the type-level list, combined
379400-- with the request's @Accept@ header, to encode the value for you
380401-- (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
402+-- was @*\/\*@, we return encode using the first @Content-Type@ type on the
382403-- list.
383−instance ( AllCTRender ctypes a
404+instance
405+#if MIN_VERSION_base(4,8,0)
406+ {-# OVERLAPPABLE #-}
407+#endif
408+ ( AllCTRender ctypes a
384409 ) => HasServer (Post ctypes a) where
385410
386411 type ServerT' (Post ctypes a) m = m a
@@ -390,7 +415,7 @@ instance ( AllCTRender ctypes a
390415 e <- runEitherT action
391416 respond $ case e of
392417 Right output -> do
393− let accH = fromMaybe "*/*" $ lookup hAccept $ requestHeaders request
418+ let accH = fromMaybe ct_wildcard $ lookup hAccept $ requestHeaders request
394419 case handleAcceptH (Proxy :: Proxy ctypes) (AcceptHeader accH) output of
395420 Nothing -> failWith UnsupportedMediaType
396421 Just (contentT, body) -> succeedWith $
@@ -401,8 +426,14 @@ instance ( AllCTRender ctypes a
401426 respond $ failWith WrongMethod
402427 | otherwise = respond $ failWith NotFound
403428
404−instance HasServer (Post ctypes ()) where
429+instance
430+#if MIN_VERSION_base(4,8,0)
431+ {-# OVERLAPPING #-}
432+#endif
433+ HasServer (Post ctypes ()) where
434+
405435 type ServerT' (Post ctypes ()) m = m ()
436+
406437 route Proxy action request respond
407438 | pathIsEmpty request && requestMethod request == methodPost = do
408439 e <- runEitherT action
@@ -415,14 +446,20 @@ instance HasServer (Post ctypes ()) where
415446 | otherwise = respond $ failWith NotFound
416447
417448-- Add response headers
418−instance ( AllCTRender ctypes v ) => HasServer (Post ctypes (Headers h v)) where
449+instance
450+#if MIN_VERSION_base(4,8,0)
451+ {-# OVERLAPPING #-}
452+#endif
453+ ( AllCTRender ctypes v ) => HasServer (Post ctypes (Headers h v)) where
454+
419455 type ServerT' (Post ctypes (Headers h v)) m = m (Headers h v)
456+
420457 route Proxy action request respond
421458 | pathIsEmpty request && requestMethod request == methodPost = do
422459 e <- runEitherT action
423460 respond $ case e of
424461 Right output -> do
425− let accH = fromMaybe "*/*" $ lookup hAccept $ requestHeaders request
462+ let accH = fromMaybe ct_wildcard $ lookup hAccept $ requestHeaders request
426463 headers = getHeaders output
427464 case handleAcceptH (Proxy :: Proxy ctypes) (AcceptHeader accH) (getResponse output) of
428465 Nothing -> failWith UnsupportedMediaType
@@ -445,10 +482,13 @@ instance ( AllCTRender ctypes v ) => HasServer (Post ctypes (Headers h v)) where
445482-- If successfully returning a value, we use the type-level list, combined
446483-- with the request's @Accept@ header, to encode the value for you
447484-- (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
485+-- was @*\/\*@, we return encode using the first @Content-Type@ type on the
449486-- list.
450−instance ( AllCTRender ctypes a
451− ) => HasServer (Put ctypes a) where
487+instance
488+#if MIN_VERSION_base(4,8,0)
489+ {-# OVERLAPPABLE #-}
490+#endif
491+ ( AllCTRender ctypes a) => HasServer (Put ctypes a) where
452492
453493 type ServerT' (Put ctypes a) m = m a
454494
@@ -457,7 +497,7 @@ instance ( AllCTRender ctypes a
457497 e <- runEitherT action
458498 respond $ case e of
459499 Right output -> do
460− let accH = fromMaybe "*/*" $ lookup hAccept $ requestHeaders request
500+ let accH = fromMaybe ct_wildcard $ lookup hAccept $ requestHeaders request
461501 case handleAcceptH (Proxy :: Proxy ctypes) (AcceptHeader accH) output of
462502 Nothing -> failWith UnsupportedMediaType
463503 Just (contentT, body) -> succeedWith $
@@ -468,8 +508,14 @@ instance ( AllCTRender ctypes a
468508 respond $ failWith WrongMethod
469509 | otherwise = respond $ failWith NotFound
470510
471−instance HasServer (Put ctypes ()) where
511+instance
512+#if MIN_VERSION_base(4,8,0)
513+ {-# OVERLAPPING #-}
514+#endif
515+ HasServer (Put ctypes ()) where
516+
472517 type ServerT' (Put ctypes ()) m = m ()
518+
473519 route Proxy action request respond
474520 | pathIsEmpty request && requestMethod request == methodPut = do
475521 e <- runEitherT action
@@ -482,14 +528,20 @@ instance HasServer (Put ctypes ()) where
482528 | otherwise = respond $ failWith NotFound
483529
484530-- Add response headers
485−instance ( AllCTRender ctypes v ) => HasServer (Put ctypes (Headers h v)) where
531+instance
532+#if MIN_VERSION_base(4,8,0)
533+ {-# OVERLAPPING #-}
534+#endif
535+ ( AllCTRender ctypes v ) => HasServer (Put ctypes (Headers h v)) where
536+
486537 type ServerT' (Put ctypes (Headers h v)) m = m (Headers h v)
538+
487539 route Proxy action request respond
488540 | pathIsEmpty request && requestMethod request == methodPut = do
489541 e <- runEitherT action
490542 respond $ case e of
491543 Right output -> do
492− let accH = fromMaybe "*/*" $ lookup hAccept $ requestHeaders request
544+ let accH = fromMaybe ct_wildcard $ lookup hAccept $ requestHeaders request
493545 headers = getHeaders output
494546 case handleAcceptH (Proxy :: Proxy ctypes) (AcceptHeader accH) (getResponse output) of
495547 Nothing -> failWith UnsupportedMediaType
@@ -512,8 +564,12 @@ instance ( AllCTRender ctypes v ) => HasServer (Put ctypes (Headers h v)) where
512564-- If successfully returning a value, we just require that its type has
513565-- a 'ToJSON' instance and servant takes care of encoding it for you,
514566-- yielding status code 200 along the way.
515−instance ( AllCTRender ctypes a
516− ) => HasServer (Patch ctypes a) where
567+instance
568+#if MIN_VERSION_base(4,8,0)
569+ {-# OVERLAPPABLE #-}
570+#endif
571+ ( AllCTRender ctypes a) => HasServer (Patch ctypes a) where
572+
517573 type ServerT' (Patch ctypes a) m = m a
518574
519575 route Proxy action request respond
@@ -521,7 +577,7 @@ instance ( AllCTRender ctypes a
521577 e <- runEitherT action
522578 respond $ case e of
523579 Right output -> do
524− let accH = fromMaybe "*/*" $ lookup hAccept $ requestHeaders request
580+ let accH = fromMaybe ct_wildcard $ lookup hAccept $ requestHeaders request
525581 case handleAcceptH (Proxy :: Proxy ctypes) (AcceptHeader accH) output of
526582 Nothing -> failWith UnsupportedMediaType
527583 Just (contentT, body) -> succeedWith $
@@ -532,8 +588,14 @@ instance ( AllCTRender ctypes a
532588 respond $ failWith WrongMethod
533589 | otherwise = respond $ failWith NotFound
534590
535−instance HasServer (Patch ctypes ()) where
591+instance
592+#if MIN_VERSION_base(4,8,0)
593+ {-# OVERLAPPING #-}
594+#endif
595+ HasServer (Patch ctypes ()) where
596+
536597 type ServerT' (Patch ctypes ()) m = m ()
598+
537599 route Proxy action request respond
538600 | pathIsEmpty request && requestMethod request == methodPatch = do
539601 e <- runEitherT action
@@ -546,14 +608,20 @@ instance HasServer (Patch ctypes ()) where
546608 | otherwise = respond $ failWith NotFound
547609
548610-- Add response headers
549−instance ( AllCTRender ctypes v ) => HasServer (Patch ctypes (Headers h v)) where
611+instance
612+#if MIN_VERSION_base(4,8,0)
613+ {-# OVERLAPPING #-}
614+#endif
615+ ( AllCTRender ctypes v ) => HasServer (Patch ctypes (Headers h v)) where
616+
550617 type ServerT' (Patch ctypes (Headers h v)) m = m (Headers h v)
618+
551619 route Proxy action request respond
552620 | pathIsEmpty request && requestMethod request == methodPatch = do
553621 e <- runEitherT action
554622 respond $ case e of
555623 Right outpatch -> do
556− let accH = fromMaybe "*/*" $ lookup hAccept $ requestHeaders request
624+ let accH = fromMaybe ct_wildcard $ lookup hAccept $ requestHeaders request
557625 headers = getHeaders outpatch
558626 case handleAcceptH (Proxy :: Proxy ctypes) (AcceptHeader accH) (getResponse outpatch) of
559627 Nothing -> failWith UnsupportedMediaType
@@ -864,3 +932,6 @@ instance (KnownSymbol path, HasServer sublayout) => HasServer (path :> sublayout
864932 _ -> respond $ failWith NotFound
865933
866934 where proxyPath = Proxy :: Proxy path
935+
936+ct_wildcard :: B.ByteString
937+ct_wildcard = "*" <> "/" <> "*" -- Because CPP
servant/servant.png → servant.pngrenamed

Binary file not shown.

servant/default.nix+20−10
@@ -1,12 +1,22 @@
1−{ pkgs ? import <nixpkgs> { config.allowUnfree = true; }
2−, src ? builtins.filterSource (path: type:
3− type != "unknown" &&
4− baseNameOf path != ".git" &&
5− baseNameOf path != "result" &&
6− baseNameOf path != "dist") ./.
1+{ mkDerivation, aeson, attoparsec, base, bytestring
2+, bytestring-conversion, case-insensitive, doctest, filemanip
3+, hspec, http-media, http-types, network-uri, parsec, QuickCheck
4+, quickcheck-instances, stdenv, string-conversions, text, url
75}:
8−pkgs.haskellPackages.buildLocalCabalWithArgs {
9− name = "servant";
10− inherit src;
11− args = {};
6+mkDerivation {
7+ pname = "servant";
8+ version = "0.2.2";
9+ src = ./.;
10+ buildDepends = [
11+ aeson attoparsec base bytestring bytestring-conversion
12+ case-insensitive http-media http-types network-uri
13+ string-conversions text
14+ ];
15+ testDepends = [
16+ aeson attoparsec base bytestring doctest filemanip hspec parsec
17+ QuickCheck quickcheck-instances string-conversions text url
18+ ];
19+ homepage = "http://haskell-servant.github.io/";
20+ description = "A family of combinators for defining webservices APIs";
21+ license = stdenv.lib.licenses.bsd3;
1222}
servant/servant.cabal+4−3
@@ -8,6 +8,8 @@ description:
88 .
99 <https://github.com/haskell-servant/servant-server/blob/master/example/greet.hs Here>'s a runnable example, with comments, that defines a dummy API and
1010 implements a webserver that serves this API, using the <http://hackage.haskell.org/package/servant-server servant-server> package.
11+ .
12+ <https://github.com/haskell-servant/servant/blob/master/servant/CHANGELOG.md CHANGELOG>
1113homepage: http://haskell-servant.github.io/
1214Bug-reports: http://github.com/haskell-servant/servant/issues
1315license: BSD3
@@ -53,13 +55,12 @@ library
5355 , http-media >= 0.4 && < 0.7
5456 , http-types == 0.8.*
5557 , text >= 1 && < 2
56− , template-haskell >= 2.7 && < 2.10
57− , parsec >= 3.1
5858 , string-conversions >= 0.3 && < 0.4
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
sources.txtnew file+5
@@ -0,0 +1,5 @@
1+servant
2+servant-client
3+servant-docs
4+servant-jquery
5+servant-server