git.iko.soy/typeable/servant
on master help sign in
Merge pull request #747 from phadej/release-0.11
71ed8b3Oleg Grenrus
.travis.yml+1−1
@@ -4,8 +4,8 @@ language: c
4
4
5env:
5env:
6 - STACK_YAML=stack-ghc-7.8.4.yaml
6 - STACK_YAML=stack-ghc-7.8.4.yaml
7+ - STACK_YAML=stack-ghc-7.10.3.yaml
7 - STACK_YAML=stack.yaml
8 - STACK_YAML=stack.yaml
8− - STACK_YAML=stack-ghc-8.0.2.yaml
9
9
10addons:
10addons:
11 apt:
11 apt:
README.md+13−13
@@ -21,19 +21,19 @@ list](https://groups.google.com/forum/#!forum/haskell-servant).
21This table lists the versions of some `servant-` libraries at the point of
21This table lists the versions of some `servant-` libraries at the point of
22release of `servant` package.
22release of `servant` package.
23
23
24−| | **0.10** |
24+| | **0.10** | **0.11** |
25−| ------------------- | -------- |
25+| ------------------- | -------- |-----------
26−| servant | 0.10 |
26+| servant | 0.10 | 0.11 |
27−| servant-blaze | 0.7.1 |
27+| servant-blaze | 0.7.1 | ? |
28−| servant-cassava | 0.7 |
28+| servant-cassava | 0.7 | ? |
29−| servant-client | 0.10 |
29+| servant-client | 0.10 | 0.11 |
30−| servant-docs | 0.10 |
30+| servant-docs | 0.10 | 0.10.1 |
31−| servant-foreign | 0.10 |
31+| servant-foreign | 0.10 | 0.10.0.1 |
32−| servant-js | 0.9.1 |
32+| servant-js | 0.9.1 | ? |
33−| servant-lucid | 0.7.1 |
33+| servant-lucid | 0.7.1 | ? |
34−| servant-mock | 0.8.1.1 |
34+| servant-mock | 0.8.1.1 | ? |
35−| servant-server | 0.10 |
35+| servant-server | 0.10 | 0.11 |
36−| servant-swagger | 1.1.2.1 |
36+| servant-swagger | 1.1.2.1 | ? |
37
37
38## Contributing
38## Contributing
39
39
doc/tutorial/tutorial.cabal+3−3
@@ -25,9 +25,9 @@ library
25 , directory
25 , directory
26 , blaze-markup
26 , blaze-markup
27 , containers
27 , containers
28− , servant == 0.10.*
28+ , servant == 0.11.*
29− , servant-server == 0.10.*
29+ , servant-server == 0.11.*
30− , servant-client == 0.10.*
30+ , servant-client == 0.11.*
31 , servant-docs == 0.10.*
31 , servant-docs == 0.10.*
32 , servant-js >= 0.9 && <0.10
32 , servant-js >= 0.9 && <0.10
33 , warp
33 , warp
servant-client/CHANGELOG.md+12
@@ -1,3 +1,15 @@
1+0.11
2+----
3+
4+### Other changes
5+
6+- Path components are escaped
7+ ([#696](https://github.com/haskell-servant/servant/pull/696))
8+- `Req` `reqPath` field changed from `String` to `BS.Builder`
9+ ([#696](https://github.com/haskell-servant/servant/pull/696))
10+- Include `Req` in failure errors
11+ ([#740](https://github.com/haskell-servant/servant/pull/740))
12+
10.10
130.10
2-----
14-----
3
15
servant-client/servant-client.cabal+4−4
@@ -1,5 +1,5 @@
1name: servant-client
1name: servant-client
2−version: 0.10
2+version: 0.11
3synopsis: automatical derivation of querying functions for servant webservices
3synopsis: automatical derivation of querying functions for servant webservices
4description:
4description:
5 This library lets you derive automatically Haskell functions that
5 This library lets you derive automatically Haskell functions that
@@ -53,7 +53,7 @@ library
53 , network-uri >= 2.6 && < 2.7
53 , network-uri >= 2.6 && < 2.7
54 , safe >= 0.3.9 && < 0.4
54 , safe >= 0.3.9 && < 0.4
55 , semigroupoids >= 4.3 && < 5.3
55 , semigroupoids >= 4.3 && < 5.3
56− , servant == 0.10.*
56+ , servant == 0.11.*
57 , string-conversions >= 0.3 && < 0.5
57 , string-conversions >= 0.3 && < 0.5
58 , text >= 1.2 && < 1.3
58 , text >= 1.2 && < 1.3
59 , transformers >= 0.3 && < 0.6
59 , transformers >= 0.3 && < 0.6
@@ -94,9 +94,9 @@ test-suite spec
94 , mtl
94 , mtl
95 , network >= 2.6
95 , network >= 2.6
96 , QuickCheck >= 2.7
96 , QuickCheck >= 2.7
97− , servant == 0.10.*
97+ , servant
98 , servant-client
98 , servant-client
99− , servant-server == 0.10.*
99+ , servant-server == 0.11.*
100 , text
100 , text
101 , transformers
101 , transformers
102 , transformers-compat
102 , transformers-compat
servant-docs/servant-docs.cabal+2−2
@@ -1,5 +1,5 @@
1name: servant-docs
1name: servant-docs
2−version: 0.10
2+version: 0.10.0.1
3synopsis: generate API docs for your servant webservice
3synopsis: generate API docs for your servant webservice
4description:
4description:
5 Library for generating API docs from a servant API definition.
5 Library for generating API docs from a servant API definition.
@@ -42,7 +42,7 @@ library
42 , http-media >= 0.6
42 , http-media >= 0.6
43 , http-types >= 0.7
43 , http-types >= 0.7
44 , lens
44 , lens
45− , servant == 0.10.*
45+ , servant == 0.11.*
46 , string-conversions
46 , string-conversions
47 , text
47 , text
48 , unordered-containers
48 , unordered-containers
servant-foreign/CHANGELOG.md+9
@@ -1,3 +1,12 @@
1+0.10.1
2+------
3+
4+### Changes
5+
6+* Don't drop samples in `HasDocs ReqBody` instance
7+ ([#755](https://github.com/haskell-servant/servant/pull/755/files)).
8+ *Breaking change in an `Internal` module*.
9+
10.10
100.10
2----
11----
3
12
servant-foreign/servant-foreign.cabal+2−2
@@ -1,5 +1,5 @@
1name: servant-foreign
1name: servant-foreign
2−version: 0.10
2+version: 0.10.1
3synopsis: Helpers for generating clients for servant APIs in any programming language
3synopsis: Helpers for generating clients for servant APIs in any programming language
4description:
4description:
5 Helper types and functions for generating client functions for servant APIs in any programming language
5 Helper types and functions for generating client functions for servant APIs in any programming language
@@ -32,7 +32,7 @@ library
32 , Servant.Foreign.Inflections
32 , Servant.Foreign.Inflections
33 build-depends: base == 4.*
33 build-depends: base == 4.*
34 , lens == 4.*
34 , lens == 4.*
35− , servant == 0.10.*
35+ , servant == 0.11.*
36 , text >= 1.2 && < 1.3
36 , text >= 1.2 && < 1.3
37 , http-types
37 , http-types
38 hs-source-dirs: src
38 hs-source-dirs: src
servant-server/CHANGELOG.md+10
@@ -1,7 +1,17 @@
10.11
10.11
2----
2----
3+
4+### Breaking changes
5+
3* Changed `HasServer` instances for `Header` to throw 400 when parsing fails
6* Changed `HasServer` instances for `Header` to throw 400 when parsing fails
7+ ([#724](https://github.com/haskell-servant/servant/pull/724))
4* Added `headersD` block to `Delayed`
8* Added `headersD` block to `Delayed`
9+ ([#724](https://github.com/haskell-servant/servant/pull/724))
10+
11+### Other changes
12+
13+* Add `err418`, `err422` error codes
14+ ([#739](https://github.com/haskell-servant/servant/pull/739))
5
15
60.10
160.10
7----
17----
servant-server/Setup.lhs+17−148
@@ -1,165 +1,34 @@
1\begin{code}
1\begin{code}
2{-# LANGUAGE CPP #-}
2{-# LANGUAGE CPP #-}
3−#ifndef MIN_VERSION_Cabal
3+{-# OPTIONS_GHC -Wall #-}
4−#define MIN_VERSION_Cabal(x,y,z) 0
5−#endif
6−#ifndef MIN_VERSION_directory
7−#define MIN_VERSION_directory(x,y,z) 0
8−#endif
9−#if MIN_VERSION_Cabal(1,24,0)
10−#define InstalledPackageId UnitId
11−#endif
12module Main (main) where
4module Main (main) where
13
5
14−import Control.Monad ( when )
6+#ifndef MIN_VERSION_cabal_doctest
15−import Data.List ( nub )
7+#define MIN_VERSION_cabal_doctest(x,y,z) 0
16−import Distribution.Package ( InstalledPackageId )
17−import Distribution.Package ( PackageId, Package (..), packageVersion )
18−import Distribution.PackageDescription ( PackageDescription(), TestSuite(..) , Library (..), BuildInfo (..))
19−import Distribution.Simple ( defaultMainWithHooks, UserHooks(..), simpleUserHooks )
20−import Distribution.Simple.Utils ( rewriteFile, createDirectoryIfMissingVerbose )
21−import Distribution.Simple.BuildPaths ( autogenModulesDir )
22−import Distribution.Simple.Setup ( BuildFlags(buildDistPref, buildVerbosity), fromFlag)
23−import Distribution.Simple.LocalBuildInfo ( withPackageDB, withLibLBI, withTestLBI, LocalBuildInfo(), ComponentLocalBuildInfo(componentPackageDeps), compiler )
24−import Distribution.Simple.Compiler ( showCompilerId , PackageDB (..))
25−import Distribution.Text ( display , simpleParse )
26−import System.FilePath ( (</>) )
27−
28−#if MIN_VERSION_Cabal(1,25,0)
29−import Distribution.Simple.BuildPaths ( autogenComponentModulesDir )
30#endif
8#endif
31
9
32−#if MIN_VERSION_directory(1,2,2)
10+#if MIN_VERSION_cabal_doctest(1,0,0)
33−import System.Directory (makeAbsolute)
34−#else
35−import System.Directory (getCurrentDirectory)
36−import System.FilePath (isAbsolute)
37−
38−makeAbsolute :: FilePath -> IO FilePath
39−makeAbsolute p | isAbsolute p = return p
40− | otherwise = do
41− cwd <- getCurrentDirectory
42− return $ cwd </> p
43−#endif
44
11
12+import Distribution.Extra.Doctest ( defaultMainWithDoctests )
45main :: IO ()
13main :: IO ()
46−main = defaultMainWithHooks simpleUserHooks
14+main = defaultMainWithDoctests "doctests"
47− { buildHook = \pkg lbi hooks flags -> do
48− generateBuildModule flags pkg lbi
49− buildHook simpleUserHooks pkg lbi hooks flags
50− }
51−
52−generateBuildModule :: BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
53−generateBuildModule flags pkg lbi = do
54− let verbosity = fromFlag (buildVerbosity flags)
55− let distPref = fromFlag (buildDistPref flags)
56−
57− -- Package DBs
58− let dbStack = withPackageDB lbi ++ [ SpecificPackageDB $ distPref </> "package.conf.inplace" ]
59− let dbFlags = "-hide-all-packages" : packageDbArgs dbStack
60−
61− withLibLBI pkg lbi $ \lib libcfg -> do
62− let libBI = libBuildInfo lib
63−
64− -- modules
65− let modules = exposedModules lib ++ otherModules libBI
66− -- it seems that doctest is happy to take in module names, not actual files!
67− let module_sources = modules
68
15
69− -- We need the directory with library's cabal_macros.h!
70−#if MIN_VERSION_Cabal(1,25,0)
71− let libAutogenDir = autogenComponentModulesDir lbi libcfg
72#else
16#else
73− let libAutogenDir = autogenModulesDir lbi
74−#endif
75−
76− -- Lib sources and includes
77− iArgs <- mapM (fmap ("-i"++) . makeAbsolute) $ libAutogenDir : hsSourceDirs libBI
78− includeArgs <- mapM (fmap ("-I"++) . makeAbsolute) $ includeDirs libBI
79−
80− -- CPP includes, i.e. include cabal_macros.h
81− let cppFlags = map ("-optP"++) $
82− [ "-include", libAutogenDir ++ "/cabal_macros.h" ]
83− ++ cppOptions libBI
84
17
85− -- Actually we need to check whether testName suite == "doctests"
86− -- pending https://github.com/haskell/cabal/pull/4229 getting into GHC HEAD tree
87− withTestLBI pkg lbi $ \suite suitecfg -> when (testName suite == "doctests") $ do
88−
89− -- get and create autogen dir
90−#if MIN_VERSION_Cabal(1,25,0)
18+#ifdef MIN_VERSION_Cabal
91− let testAutogenDir = autogenComponentModulesDir lbi suitecfg
19+-- If the macro is defined, we have new cabal-install,
92−#else
20+-- but for some reason we don't have cabal-doctest in package-db
93− let testAutogenDir = autogenModulesDir lbi
21+--
22+-- Probably we are running cabal sdist, when otherwise using new-build
23+-- workflow
24+import Warning ()
94#endif
25#endif
95− createDirectoryIfMissingVerbose verbosity True testAutogenDir
96
26
97− -- write autogen'd file
27+import Distribution.Simple
98− rewriteFile (testAutogenDir </> "Build_doctests.hs") $ unlines
99− [ "module Build_doctests where"
100− , ""
101− -- -package-id etc. flags
102− , "pkgs :: [String]"
103− , "pkgs = " ++ (show $ formatDeps $ testDeps libcfg suitecfg)
104− , ""
105− , "flags :: [String]"
106− , "flags = " ++ show (iArgs ++ includeArgs ++ dbFlags ++ cppFlags)
107− , ""
108− , "module_sources :: [String]"
109− , "module_sources = " ++ show (map display module_sources)
110− ]
111− where
112− -- we do this check in Setup, as then doctests don't need to depend on Cabal
113− isOldCompiler = maybe False id $ do
114− a <- simpleParse $ showCompilerId $ compiler lbi
115− b <- simpleParse "7.5"
116− return $ packageVersion (a :: PackageId) < b
117
28
118− formatDeps = map formatOne
29+main :: IO ()
119− formatOne (installedPkgId, pkgId)
30+main = defaultMain
120− -- The problem is how different cabal executables handle package databases
121− -- when doctests depend on the library
122− | packageId pkg == pkgId = "-package=" ++ display pkgId
123− | otherwise = "-package-id=" ++ display installedPkgId
124−
125− -- From Distribution.Simple.Program.GHC
126− packageDbArgs :: [PackageDB] -> [String]
127− packageDbArgs | isOldCompiler = packageDbArgsConf
128− | otherwise = packageDbArgsDb
129−
130− -- GHC <7.6 uses '-package-conf' instead of '-package-db'.
131− packageDbArgsConf :: [PackageDB] -> [String]
132− packageDbArgsConf dbstack = case dbstack of
133− (GlobalPackageDB:UserPackageDB:dbs) -> concatMap specific dbs
134− (GlobalPackageDB:dbs) -> ("-no-user-package-conf")
135− : concatMap specific dbs
136− _ -> ierror
137− where
138− specific (SpecificPackageDB db) = [ "-package-conf=" ++ db ]
139− specific _ = ierror
140− ierror = error $ "internal error: unexpected package db stack: "
141− ++ show dbstack
142−
143− -- GHC >= 7.6 uses the '-package-db' flag. See
144− -- https://ghc.haskell.org/trac/ghc/ticket/5977.
145− packageDbArgsDb :: [PackageDB] -> [String]
146− -- special cases to make arguments prettier in common scenarios
147− packageDbArgsDb dbstack = case dbstack of
148− (GlobalPackageDB:UserPackageDB:dbs)
149− | all isSpecific dbs -> concatMap single dbs
150− (GlobalPackageDB:dbs)
151− | all isSpecific dbs -> "-no-user-package-db"
152− : concatMap single dbs
153− dbs -> "-clear-package-db"
154− : concatMap single dbs
155− where
156− single (SpecificPackageDB db) = [ "-package-db=" ++ db ]
157− single GlobalPackageDB = [ "-global-package-db" ]
158− single UserPackageDB = [ "-user-package-db" ]
159− isSpecific (SpecificPackageDB _) = True
160− isSpecific _ = False
161
31
162−testDeps :: ComponentLocalBuildInfo -> ComponentLocalBuildInfo -> [(InstalledPackageId, PackageId)]
32+#endif
163−testDeps xs ys = nub $ componentPackageDeps xs ++ componentPackageDeps ys
164
33
165\end{code}
34\end{code}
servant-server/servant-server.cabal+7−3
@@ -1,5 +1,5 @@
1name: servant-server
1name: servant-server
2−version: 0.10
2+version: 0.11
3synopsis: A family of combinators for defining webservices APIs and serving them
3synopsis: A family of combinators for defining webservices APIs and serving them
4description:
4description:
5 A family of combinators for defining webservices APIs and serving them
5 A family of combinators for defining webservices APIs and serving them
@@ -33,7 +33,9 @@ source-repository head
33
33
34custom-setup
34custom-setup
35 setup-depends:
35 setup-depends:
36− Cabal >=1.14, base, filepath, directory
36+ base >= 4 && <5,
37+ Cabal,
38+ cabal-doctest >= 1.0.1 && <1.1
37
39
38library
40library
39 exposed-modules:
41 exposed-modules:
@@ -64,7 +66,7 @@ library
64 , mtl >= 2 && < 2.3
66 , mtl >= 2 && < 2.3
65 , network >= 2.6 && < 2.7
67 , network >= 2.6 && < 2.7
66 , safe >= 0.3 && < 0.4
68 , safe >= 0.3 && < 0.4
67− , servant == 0.10.*
69+ , servant == 0.11.*
68 , split >= 0.2 && < 0.3
70 , split >= 0.2 && < 0.3
69 , string-conversions >= 0.3 && < 0.5
71 , string-conversions >= 0.3 && < 0.5
70 , system-filepath >= 0.4 && < 0.5
72 , system-filepath >= 0.4 && < 0.5
@@ -159,4 +161,6 @@ test-suite doctests
159 buildable: True
161 buildable: True
160 default-language: Haskell2010
162 default-language: Haskell2010
161 ghc-options: -Wall -threaded
163 ghc-options: -Wall -threaded
164+ if impl(ghc >= 8.2)
165+ x-doctest-options: -fdiagnostics-color=never
162 include-dirs: include
166 include-dirs: include
servant-server/src/Servant/Server.hs+2
@@ -228,5 +228,7 @@ layoutWithContext p context =
228--
228--
229
229
230-- $setup
230-- $setup
231+-- >>> :set -XDataKinds
232+-- >>> :set -XTypeOperators
231-- >>> import Servant.API
233-- >>> import Servant.API
232-- >>> import Servant.Server
234-- >>> import Servant.Server
servant-server/test/doctests.hsnew file+25
@@ -0,0 +1,25 @@
1+-----------------------------------------------------------------------------
2+-- |
3+-- Module : Main (doctests)
4+-- Copyright : (C) 2012-14 Edward Kmett
5+-- License : BSD-style (see the file LICENSE)
6+-- Maintainer : Edward Kmett <ekmett@gmail.com>
7+-- Stability : provisional
8+-- Portability : portable
9+--
10+-- This module provides doctests for a project based on the actual versions
11+-- of the packages it was built with. It requires a corresponding Setup.lhs
12+-- to be added to the project
13+-----------------------------------------------------------------------------
14+module Main where
15+
16+import Build_doctests (flags, pkgs, module_sources)
17+import Data.Foldable (traverse_)
18+import Test.DocTest
19+
20+main :: IO ()
21+main = do
22+ traverse_ putStrLn args
23+ doctest args
24+ where
25+ args = flags ++ pkgs ++ module_sources
servant-server/test/doctests.hscdeleted−61
@@ -1,61 +0,0 @@
1−{-# LANGUAGE CPP #-}
2−{-# LANGUAGE ForeignFunctionInterface #-}
3−-----------------------------------------------------------------------------
4−-- |
5−-- Module : Main (doctests)
6−-- Copyright : (C) 2012-14 Edward Kmett
7−-- License : BSD-style (see the file LICENSE)
8−-- Maintainer : Edward Kmett <ekmett@gmail.com>
9−-- Stability : provisional
10−-- Portability : portable
11−--
12−-- This module provides doctests for a project based on the actual versions
13−-- of the packages it was built with. It requires a corresponding Setup.lhs
14−-- to be added to the project
15−-----------------------------------------------------------------------------
16−module Main where
17−
18−import Build_doctests (flags, pkgs, module_sources)
19−import Data.Foldable (traverse_)
20−import Test.DocTest
21−
22−##if defined(mingw32_HOST_OS)
23−##if defined(i386_HOST_ARCH)
24−##define USE_CP
25−import Control.Applicative
26−import Control.Exception
27−import Foreign.C.Types
28−foreign import stdcall "windows.h SetConsoleCP" c_SetConsoleCP :: CUInt -> IO Bool
29−foreign import stdcall "windows.h GetConsoleCP" c_GetConsoleCP :: IO CUInt
30−##elif defined(x86_64_HOST_ARCH)
31−##define USE_CP
32−import Control.Applicative
33−import Control.Exception
34−import Foreign.C.Types
35−foreign import ccall "windows.h SetConsoleCP" c_SetConsoleCP :: CUInt -> IO Bool
36−foreign import ccall "windows.h GetConsoleCP" c_GetConsoleCP :: IO CUInt
37−##endif
38−##endif
39−
40−-- | Run in a modified codepage where we can print UTF-8 values on Windows.
41−withUnicode :: IO a -> IO a
42−##ifdef USE_CP
43−withUnicode m = do
44− cp <- c_GetConsoleCP
45− (c_SetConsoleCP 65001 >> m) `finally` c_SetConsoleCP cp
46−##else
47−withUnicode m = m
48−##endif
49−
50−main :: IO ()
51−main = withUnicode $ do
52− traverse_ putStrLn args
53− doctest args
54− where
55− args =
56− "-XOverloadedStrings" :
57− "-XFlexibleInstances" :
58− "-XMultiParamTypeClasses" :
59− "-XDataKinds" :
60− "-XTypeOperators" :
61− flags ++ pkgs ++ module_sources
servant/CHANGELOG.md+31−1
@@ -1,5 +1,35 @@
1+0.11
2+----
3+
4+### Breaking changes
5+
6+- `Enter` refactored
7+ ([#734](https://github.com/haskell-servant/servant/issues/734)
8+ , [#736](https://github.com/haskell-servant/servant/pull/736))
9+
10+### Other changes
11+
12+- Add a type representing an empty API
13+ ([#753](https://github.com/haskell-servant/servant/pull/753))
14+- Add `linkURI'` and `Link` accessors
15+ ([#745](https://github.com/haskell-servant/servant/pull/745)
16+ , [#717](https://github.com/haskell-servant/servant/pull/717)
17+ , [#715](https://github.com/haskell-servant/servant/issues/715))
18+- Prepare for GHC-8.2
19+ ([#722](https://github.com/haskell-servant/servant/pull/722))
20+- Add `HasLink AuthProtect` instance
21+ ([#720](https://github.com/haskell-servant/servant/pull/720))
22+- `AllCTRender [] ()` `TypeError` (use `NoContent`)
23+ ([#671](https://github.com/haskell-servant/servant/pull/671))
24+- Documentation improvements and typo fixes
25+ ([#702](https://github.com/haskell-servant/servant/pull/702)
26+ , [#709](https://github.com/haskell-servant/servant/pull/709)
27+ , [#716](https://github.com/haskell-servant/servant/pull/716)
28+ , [#725](https://github.com/haskell-servant/servant/pull/725)
29+ , [#727](https://github.com/haskell-servant/servant/pull/727))
30+
10.10
310.10
2−------
32+----
3
33
4### Breaking changes
34### Breaking changes
5
35
servant/Setup.lhs+17−148
@@ -1,165 +1,34 @@
1\begin{code}
1\begin{code}
2{-# LANGUAGE CPP #-}
2{-# LANGUAGE CPP #-}
3−#ifndef MIN_VERSION_Cabal
3+{-# OPTIONS_GHC -Wall #-}
4−#define MIN_VERSION_Cabal(x,y,z) 0
5−#endif
6−#ifndef MIN_VERSION_directory
7−#define MIN_VERSION_directory(x,y,z) 0
8−#endif
9−#if MIN_VERSION_Cabal(1,24,0)
10−#define InstalledPackageId UnitId
11−#endif
12module Main (main) where
4module Main (main) where
13
5
14−import Control.Monad ( when )
6+#ifndef MIN_VERSION_cabal_doctest
15−import Data.List ( nub )
7+#define MIN_VERSION_cabal_doctest(x,y,z) 0
16−import Distribution.Package ( InstalledPackageId )
17−import Distribution.Package ( PackageId, Package (..), packageVersion )
18−import Distribution.PackageDescription ( PackageDescription(), TestSuite(..) , Library (..), BuildInfo (..))
19−import Distribution.Simple ( defaultMainWithHooks, UserHooks(..), simpleUserHooks )
20−import Distribution.Simple.Utils ( rewriteFile, createDirectoryIfMissingVerbose )
21−import Distribution.Simple.BuildPaths ( autogenModulesDir )
22−import Distribution.Simple.Setup ( BuildFlags(buildDistPref, buildVerbosity), fromFlag)
23−import Distribution.Simple.LocalBuildInfo ( withPackageDB, withLibLBI, withTestLBI, LocalBuildInfo(), ComponentLocalBuildInfo(componentPackageDeps), compiler )
24−import Distribution.Simple.Compiler ( showCompilerId , PackageDB (..))
25−import Distribution.Text ( display , simpleParse )
26−import System.FilePath ( (</>) )
27−
28−#if MIN_VERSION_Cabal(1,25,0)
29−import Distribution.Simple.BuildPaths ( autogenComponentModulesDir )
30#endif
8#endif
31
9
32−#if MIN_VERSION_directory(1,2,2)
10+#if MIN_VERSION_cabal_doctest(1,0,0)
33−import System.Directory (makeAbsolute)
34−#else
35−import System.Directory (getCurrentDirectory)
36−import System.FilePath (isAbsolute)
37−
38−makeAbsolute :: FilePath -> IO FilePath
39−makeAbsolute p | isAbsolute p = return p
40− | otherwise = do
41− cwd <- getCurrentDirectory
42− return $ cwd </> p
43−#endif
44
11
12+import Distribution.Extra.Doctest ( defaultMainWithDoctests )
45main :: IO ()
13main :: IO ()
46−main = defaultMainWithHooks simpleUserHooks
14+main = defaultMainWithDoctests "doctests"
47− { buildHook = \pkg lbi hooks flags -> do
48− generateBuildModule flags pkg lbi
49− buildHook simpleUserHooks pkg lbi hooks flags
50− }
51−
52−generateBuildModule :: BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
53−generateBuildModule flags pkg lbi = do
54− let verbosity = fromFlag (buildVerbosity flags)
55− let distPref = fromFlag (buildDistPref flags)
56−
57− -- Package DBs
58− let dbStack = withPackageDB lbi ++ [ SpecificPackageDB $ distPref </> "package.conf.inplace" ]
59− let dbFlags = "-hide-all-packages" : packageDbArgs dbStack
60−
61− withLibLBI pkg lbi $ \lib libcfg -> do
62− let libBI = libBuildInfo lib
63−
64− -- modules
65− let modules = exposedModules lib ++ otherModules libBI
66− -- it seems that doctest is happy to take in module names, not actual files!
67− let module_sources = modules
68
15
69− -- We need the directory with library's cabal_macros.h!
70−#if MIN_VERSION_Cabal(1,25,0)
71− let libAutogenDir = autogenComponentModulesDir lbi libcfg
72#else
16#else
73− let libAutogenDir = autogenModulesDir lbi
74−#endif
75−
76− -- Lib sources and includes
77− iArgs <- mapM (fmap ("-i"++) . makeAbsolute) $ "test" : libAutogenDir : hsSourceDirs libBI
78− includeArgs <- mapM (fmap ("-I"++) . makeAbsolute) $ includeDirs libBI
79−
80− -- CPP includes, i.e. include cabal_macros.h
81− let cppFlags = map ("-optP"++) $
82− [ "-include", libAutogenDir ++ "/cabal_macros.h" ]
83− ++ cppOptions libBI
84
17
85− -- Actually we need to check whether testName suite == "doctests"
86− -- pending https://github.com/haskell/cabal/pull/4229 getting into GHC HEAD tree
87− withTestLBI pkg lbi $ \suite suitecfg -> when (testName suite == "doctests") $ do
88−
89− -- get and create autogen dir
90−#if MIN_VERSION_Cabal(1,25,0)
18+#ifdef MIN_VERSION_Cabal
91− let testAutogenDir = autogenComponentModulesDir lbi suitecfg
19+-- If the macro is defined, we have new cabal-install,
92−#else
20+-- but for some reason we don't have cabal-doctest in package-db
93− let testAutogenDir = autogenModulesDir lbi
21+--
22+-- Probably we are running cabal sdist, when otherwise using new-build
23+-- workflow
24+import Warning ()
94#endif
25#endif
95− createDirectoryIfMissingVerbose verbosity True testAutogenDir
96
26
97− -- write autogen'd file
27+import Distribution.Simple
98− rewriteFile (testAutogenDir </> "Build_doctests.hs") $ unlines
99− [ "module Build_doctests where"
100− , ""
101− -- -package-id etc. flags
102− , "pkgs :: [String]"
103− , "pkgs = " ++ (show $ formatDeps $ testDeps libcfg suitecfg)
104− , ""
105− , "flags :: [String]"
106− , "flags = " ++ show (iArgs ++ includeArgs ++ dbFlags ++ cppFlags)
107− , ""
108− , "module_sources :: [String]"
109− , "module_sources = " ++ show ("Servant.Utils.LinksSpec" : map display module_sources)
110− ]
111− where
112− -- we do this check in Setup, as then doctests don't need to depend on Cabal
113− isOldCompiler = maybe False id $ do
114− a <- simpleParse $ showCompilerId $ compiler lbi
115− b <- simpleParse "7.5"
116− return $ packageVersion (a :: PackageId) < b
117
28
118− formatDeps = map formatOne
29+main :: IO ()
119− formatOne (installedPkgId, pkgId)
30+main = defaultMain
120− -- The problem is how different cabal executables handle package databases
121− -- when doctests depend on the library
122− | packageId pkg == pkgId = "-package=" ++ display pkgId
123− | otherwise = "-package-id=" ++ display installedPkgId
124−
125− -- From Distribution.Simple.Program.GHC
126− packageDbArgs :: [PackageDB] -> [String]
127− packageDbArgs | isOldCompiler = packageDbArgsConf
128− | otherwise = packageDbArgsDb
129−
130− -- GHC <7.6 uses '-package-conf' instead of '-package-db'.
131− packageDbArgsConf :: [PackageDB] -> [String]
132− packageDbArgsConf dbstack = case dbstack of
133− (GlobalPackageDB:UserPackageDB:dbs) -> concatMap specific dbs
134− (GlobalPackageDB:dbs) -> ("-no-user-package-conf")
135− : concatMap specific dbs
136− _ -> ierror
137− where
138− specific (SpecificPackageDB db) = [ "-package-conf=" ++ db ]
139− specific _ = ierror
140− ierror = error $ "internal error: unexpected package db stack: "
141− ++ show dbstack
142−
143− -- GHC >= 7.6 uses the '-package-db' flag. See
144− -- https://ghc.haskell.org/trac/ghc/ticket/5977.
145− packageDbArgsDb :: [PackageDB] -> [String]
146− -- special cases to make arguments prettier in common scenarios
147− packageDbArgsDb dbstack = case dbstack of
148− (GlobalPackageDB:UserPackageDB:dbs)
149− | all isSpecific dbs -> concatMap single dbs
150− (GlobalPackageDB:dbs)
151− | all isSpecific dbs -> "-no-user-package-db"
152− : concatMap single dbs
153− dbs -> "-clear-package-db"
154− : concatMap single dbs
155− where
156− single (SpecificPackageDB db) = [ "-package-db=" ++ db ]
157− single GlobalPackageDB = [ "-global-package-db" ]
158− single UserPackageDB = [ "-user-package-db" ]
159− isSpecific (SpecificPackageDB _) = True
160− isSpecific _ = False
161
31
162−testDeps :: ComponentLocalBuildInfo -> ComponentLocalBuildInfo -> [(InstalledPackageId, PackageId)]
32+#endif
163−testDeps xs ys = nub $ componentPackageDeps xs ++ componentPackageDeps ys
164
33
165\end{code}
34\end{code}
servant/servant.cabal+8−3
@@ -1,5 +1,5 @@
1name: servant
1name: servant
2−version: 0.10
2+version: 0.11
3synopsis: A family of combinators for defining webservices APIs
3synopsis: A family of combinators for defining webservices APIs
4description:
4description:
5 A family of combinators for defining webservices APIs and serving them
5 A family of combinators for defining webservices APIs and serving them
@@ -27,7 +27,9 @@ source-repository head
27
27
28custom-setup
28custom-setup
29 setup-depends:
29 setup-depends:
30− Cabal >=1.14, base, filepath, directory
30+ base >= 4 && <5,
31+ Cabal,
32+ cabal-doctest >= 1.0.2 && <1.1
31
33
32library
34library
33 exposed-modules:
35 exposed-modules:
@@ -147,5 +149,8 @@ test-suite doctests
147 buildable: True
149 buildable: True
148 default-language: Haskell2010
150 default-language: Haskell2010
149 ghc-options: -Wall -threaded
151 ghc-options: -Wall -threaded
150− build-tools: hsc2hs
152+ if impl(ghc >= 8.2)
153+ x-doctest-options: -fdiagnostics-color=never
151 include-dirs: include
154 include-dirs: include
155+ x-doctest-source-dirs: test
156+ x-doctest-modules: Servant.Utils.LinksSpec
servant/src/Servant/API/ContentTypes.hs+3
@@ -419,6 +419,9 @@ instance MimeUnrender OctetStream BS.ByteString where
419
419
420
420
421-- $setup
421-- $setup
422+-- >>> :set -XFlexibleInstances
423+-- >>> :set -XMultiParamTypeClasses
424+-- >>> :set -XOverloadedStrings
422-- >>> import Servant.API
425-- >>> import Servant.API
423-- >>> import Data.Aeson
426-- >>> import Data.Aeson
424-- >>> import Data.Text
427-- >>> import Data.Text
servant/test/doctests.hsnew file+25
@@ -0,0 +1,25 @@
1+-----------------------------------------------------------------------------
2+-- |
3+-- Module : Main (doctests)
4+-- Copyright : (C) 2012-14 Edward Kmett
5+-- License : BSD-style (see the file LICENSE)
6+-- Maintainer : Edward Kmett <ekmett@gmail.com>
7+-- Stability : provisional
8+-- Portability : portable
9+--
10+-- This module provides doctests for a project based on the actual versions
11+-- of the packages it was built with. It requires a corresponding Setup.lhs
12+-- to be added to the project
13+-----------------------------------------------------------------------------
14+module Main where
15+
16+import Build_doctests (flags, pkgs, module_sources)
17+import Data.Foldable (traverse_)
18+import Test.DocTest
19+
20+main :: IO ()
21+main = do
22+ traverse_ putStrLn args
23+ doctest args
24+ where
25+ args = flags ++ pkgs ++ module_sources
servant/test/doctests.hscdeleted−59
@@ -1,59 +0,0 @@
1−{-# LANGUAGE CPP #-}
2−{-# LANGUAGE ForeignFunctionInterface #-}
3−-----------------------------------------------------------------------------
4−-- |
5−-- Module : Main (doctests)
6−-- Copyright : (C) 2012-14 Edward Kmett
7−-- License : BSD-style (see the file LICENSE)
8−-- Maintainer : Edward Kmett <ekmett@gmail.com>
9−-- Stability : provisional
10−-- Portability : portable
11−--
12−-- This module provides doctests for a project based on the actual versions
13−-- of the packages it was built with. It requires a corresponding Setup.lhs
14−-- to be added to the project
15−-----------------------------------------------------------------------------
16−module Main where
17−
18−import Build_doctests (flags, pkgs, module_sources)
19−import Data.Foldable (traverse_)
20−import Test.DocTest
21−
22−##if defined(mingw32_HOST_OS)
23−##if defined(i386_HOST_ARCH)
24−##define USE_CP
25−import Control.Applicative
26−import Control.Exception
27−import Foreign.C.Types
28−foreign import stdcall "windows.h SetConsoleCP" c_SetConsoleCP :: CUInt -> IO Bool
29−foreign import stdcall "windows.h GetConsoleCP" c_GetConsoleCP :: IO CUInt
30−##elif defined(x86_64_HOST_ARCH)
31−##define USE_CP
32−import Control.Applicative
33−import Control.Exception
34−import Foreign.C.Types
35−foreign import ccall "windows.h SetConsoleCP" c_SetConsoleCP :: CUInt -> IO Bool
36−foreign import ccall "windows.h GetConsoleCP" c_GetConsoleCP :: IO CUInt
37−##endif
38−##endif
39−
40−-- | Run in a modified codepage where we can print UTF-8 values on Windows.
41−withUnicode :: IO a -> IO a
42−##ifdef USE_CP
43−withUnicode m = do
44− cp <- c_GetConsoleCP
45− (c_SetConsoleCP 65001 >> m) `finally` c_SetConsoleCP cp
46−##else
47−withUnicode m = m
48−##endif
49−
50−main :: IO ()
51−main = withUnicode $ do
52− traverse_ putStrLn args
53− doctest args
54− where
55− args =
56− "-XOverloadedStrings" :
57− "-XFlexibleInstances" :
58− "-XMultiParamTypeClasses" :
59− flags ++ pkgs ++ module_sources
stack-ghc-7.10.3.yamlnew file+20
@@ -0,0 +1,20 @@
1+flags: {}
2+packages:
3+- servant/
4+- servant-client/
5+- servant-docs/
6+- servant-foreign/
7+- servant-server/
8+- doc/tutorial
9+extra-deps:
10+- attoparsec-iso8601-1.0.0.0
11+- cabal-doctest-1.0.2
12+- hspec-2.3.2
13+- hspec-core-2.3.2
14+- hspec-discover-2.3.2
15+- hspec-expectations-0.8.2
16+- hspec-wai-0.8.0
17+- http-api-data-0.3.7
18+- natural-transformation-0.4
19+- servant-js-0.9.3
20+resolver: lts-6.27
stack-ghc-7.8.4.yaml+5−3
@@ -8,18 +8,20 @@ packages:
8extra-deps:
8extra-deps:
9- aeson-compat-0.3.6
9- aeson-compat-0.3.6
10- base-compat-0.9.1
10- base-compat-0.9.1
11+- cabal-doctest-1.0.2
12+- call-stack-0.1.0
11- control-monad-omega-0.3.1
13- control-monad-omega-0.3.1
12- cryptonite-0.6
14- cryptonite-0.6
13- doctest-0.11.0
15- doctest-0.11.0
14- hspec-2.3.2
16- hspec-2.3.2
15−- hspec-discover-2.3.2
16- hspec-core-2.3.2
17- hspec-core-2.3.2
17−- hspec-wai-0.8.0
18+- hspec-discover-2.3.2
18- hspec-expectations-0.8.2
19- hspec-expectations-0.8.2
19−- call-stack-0.1.0
20+- hspec-wai-0.8.0
20- http-api-data-0.3.6
21- http-api-data-0.3.6
21- natural-transformation-0.4
22- natural-transformation-0.4
22- primitive-0.6.1.0
23- primitive-0.6.1.0
24+- servant-js-0.9.3
23- should-not-typecheck-2.1.0
25- should-not-typecheck-2.1.0
24- time-locale-compat-0.1.1.1
26- time-locale-compat-0.1.1.1
25- uri-bytestring-0.2.2.0
27- uri-bytestring-0.2.2.0
stack-ghc-8.0.2.yamldeleted−12
@@ -1,12 +0,0 @@
1−resolver: nightly-2017-04-01
2−packages:
3−- servant/
4−- servant-client/
5−- servant-docs/
6−- servant-foreign/
7−- servant-server/
8−- doc/tutorial
9−extra-deps:
10−- aeson-1.2.0.0
11−- attoparsec-iso8601-1.0.0.0
12−- http-api-data-0.3.7
stack.yaml+4−9
@@ -1,4 +1,4 @@
1−flags: {}
1+resolver: nightly-2017-04-01
2packages:
2packages:
3- servant/
3- servant/
4- servant-client/
4- servant-client/
@@ -7,13 +7,8 @@ packages:
7- servant-server/
7- servant-server/
8- doc/tutorial
8- doc/tutorial
9extra-deps:
9extra-deps:
10+- aeson-1.2.0.0
10- attoparsec-iso8601-1.0.0.0
11- attoparsec-iso8601-1.0.0.0
12+- cabal-doctest-1.0.2
11- http-api-data-0.3.7
13- http-api-data-0.3.7
12−- servant-js-0.9.1
14+- servant-js-0.9.3
13−- natural-transformation-0.4
14−- hspec-2.3.2
15−- hspec-discover-2.3.2
16−- hspec-core-2.3.2
17−- hspec-wai-0.8.0
18−- hspec-expectations-0.8.2
19−resolver: lts-6.27