Merge pull request #747 from phadej/release-0.11

Release 0.11
This commit is contained in:
Oleg Grenrus 2017-05-24 10:18:14 +03:00 committed by GitHub
commit 71ed8b3736
24 changed files with 224 additions and 476 deletions

View file

@ -4,8 +4,8 @@ language: c
env: env:
- STACK_YAML=stack-ghc-7.8.4.yaml - STACK_YAML=stack-ghc-7.8.4.yaml
- STACK_YAML=stack-ghc-7.10.3.yaml
- STACK_YAML=stack.yaml - STACK_YAML=stack.yaml
- STACK_YAML=stack-ghc-8.0.2.yaml
addons: addons:
apt: apt:

View file

@ -21,19 +21,19 @@ list](https://groups.google.com/forum/#!forum/haskell-servant).
This table lists the versions of some `servant-` libraries at the point of This table lists the versions of some `servant-` libraries at the point of
release of `servant` package. release of `servant` package.
| | **0.10** | | | **0.10** | **0.11** |
| ------------------- | -------- | | ------------------- | -------- |-----------
| servant | 0.10 | | servant | 0.10 | 0.11 |
| servant-blaze | 0.7.1 | | servant-blaze | 0.7.1 | ? |
| servant-cassava | 0.7 | | servant-cassava | 0.7 | ? |
| servant-client | 0.10 | | servant-client | 0.10 | 0.11 |
| servant-docs | 0.10 | | servant-docs | 0.10 | 0.10.1 |
| servant-foreign | 0.10 | | servant-foreign | 0.10 | 0.10.0.1 |
| servant-js | 0.9.1 | | servant-js | 0.9.1 | ? |
| servant-lucid | 0.7.1 | | servant-lucid | 0.7.1 | ? |
| servant-mock | 0.8.1.1 | | servant-mock | 0.8.1.1 | ? |
| servant-server | 0.10 | | servant-server | 0.10 | 0.11 |
| servant-swagger | 1.1.2.1 | | servant-swagger | 1.1.2.1 | ? |
## Contributing ## Contributing

View file

@ -25,9 +25,9 @@ library
, directory , directory
, blaze-markup , blaze-markup
, containers , containers
, servant == 0.10.* , servant == 0.11.*
, servant-server == 0.10.* , servant-server == 0.11.*
, servant-client == 0.10.* , servant-client == 0.11.*
, servant-docs == 0.10.* , servant-docs == 0.10.*
, servant-js >= 0.9 && <0.10 , servant-js >= 0.9 && <0.10
, warp , warp

View file

@ -1,3 +1,15 @@
0.11
----
### Other changes
- Path components are escaped
([#696](https://github.com/haskell-servant/servant/pull/696))
- `Req` `reqPath` field changed from `String` to `BS.Builder`
([#696](https://github.com/haskell-servant/servant/pull/696))
- Include `Req` in failure errors
([#740](https://github.com/haskell-servant/servant/pull/740))
0.10 0.10
----- -----

View file

@ -1,5 +1,5 @@
name: servant-client name: servant-client
version: 0.10 version: 0.11
synopsis: automatical derivation of querying functions for servant webservices synopsis: automatical derivation of querying functions for servant webservices
description: description:
This library lets you derive automatically Haskell functions that This library lets you derive automatically Haskell functions that
@ -53,7 +53,7 @@ library
, network-uri >= 2.6 && < 2.7 , network-uri >= 2.6 && < 2.7
, safe >= 0.3.9 && < 0.4 , safe >= 0.3.9 && < 0.4
, semigroupoids >= 4.3 && < 5.3 , semigroupoids >= 4.3 && < 5.3
, servant == 0.10.* , servant == 0.11.*
, string-conversions >= 0.3 && < 0.5 , string-conversions >= 0.3 && < 0.5
, text >= 1.2 && < 1.3 , text >= 1.2 && < 1.3
, transformers >= 0.3 && < 0.6 , transformers >= 0.3 && < 0.6
@ -94,9 +94,9 @@ test-suite spec
, mtl , mtl
, network >= 2.6 , network >= 2.6
, QuickCheck >= 2.7 , QuickCheck >= 2.7
, servant == 0.10.* , servant
, servant-client , servant-client
, servant-server == 0.10.* , servant-server == 0.11.*
, text , text
, transformers , transformers
, transformers-compat , transformers-compat

View file

@ -1,5 +1,5 @@
name: servant-docs name: servant-docs
version: 0.10 version: 0.10.0.1
synopsis: generate API docs for your servant webservice synopsis: generate API docs for your servant webservice
description: description:
Library for generating API docs from a servant API definition. Library for generating API docs from a servant API definition.
@ -42,7 +42,7 @@ library
, http-media >= 0.6 , http-media >= 0.6
, http-types >= 0.7 , http-types >= 0.7
, lens , lens
, servant == 0.10.* , servant == 0.11.*
, string-conversions , string-conversions
, text , text
, unordered-containers , unordered-containers

View file

@ -1,3 +1,12 @@
0.10.1
------
### Changes
* Don't drop samples in `HasDocs ReqBody` instance
([#755](https://github.com/haskell-servant/servant/pull/755/files)).
*Breaking change in an `Internal` module*.
0.10 0.10
---- ----

View file

@ -1,5 +1,5 @@
name: servant-foreign name: servant-foreign
version: 0.10 version: 0.10.1
synopsis: Helpers for generating clients for servant APIs in any programming language synopsis: Helpers for generating clients for servant APIs in any programming language
description: description:
Helper types and functions for generating client functions for servant APIs in any programming language Helper types and functions for generating client functions for servant APIs in any programming language
@ -32,7 +32,7 @@ library
, Servant.Foreign.Inflections , Servant.Foreign.Inflections
build-depends: base == 4.* build-depends: base == 4.*
, lens == 4.* , lens == 4.*
, servant == 0.10.* , servant == 0.11.*
, text >= 1.2 && < 1.3 , text >= 1.2 && < 1.3
, http-types , http-types
hs-source-dirs: src hs-source-dirs: src

View file

@ -1,7 +1,17 @@
0.11 0.11
---- ----
### Breaking changes
* Changed `HasServer` instances for `Header` to throw 400 when parsing fails * Changed `HasServer` instances for `Header` to throw 400 when parsing fails
([#724](https://github.com/haskell-servant/servant/pull/724))
* Added `headersD` block to `Delayed` * Added `headersD` block to `Delayed`
([#724](https://github.com/haskell-servant/servant/pull/724))
### Other changes
* Add `err418`, `err422` error codes
([#739](https://github.com/haskell-servant/servant/pull/739))
0.10 0.10
---- ----

View file

@ -1,165 +1,34 @@
\begin{code} \begin{code}
{-# LANGUAGE CPP #-} {-# LANGUAGE CPP #-}
#ifndef MIN_VERSION_Cabal {-# OPTIONS_GHC -Wall #-}
#define MIN_VERSION_Cabal(x,y,z) 0
#endif
#ifndef MIN_VERSION_directory
#define MIN_VERSION_directory(x,y,z) 0
#endif
#if MIN_VERSION_Cabal(1,24,0)
#define InstalledPackageId UnitId
#endif
module Main (main) where module Main (main) where
import Control.Monad ( when ) #ifndef MIN_VERSION_cabal_doctest
import Data.List ( nub ) #define MIN_VERSION_cabal_doctest(x,y,z) 0
import Distribution.Package ( InstalledPackageId )
import Distribution.Package ( PackageId, Package (..), packageVersion )
import Distribution.PackageDescription ( PackageDescription(), TestSuite(..) , Library (..), BuildInfo (..))
import Distribution.Simple ( defaultMainWithHooks, UserHooks(..), simpleUserHooks )
import Distribution.Simple.Utils ( rewriteFile, createDirectoryIfMissingVerbose )
import Distribution.Simple.BuildPaths ( autogenModulesDir )
import Distribution.Simple.Setup ( BuildFlags(buildDistPref, buildVerbosity), fromFlag)
import Distribution.Simple.LocalBuildInfo ( withPackageDB, withLibLBI, withTestLBI, LocalBuildInfo(), ComponentLocalBuildInfo(componentPackageDeps), compiler )
import Distribution.Simple.Compiler ( showCompilerId , PackageDB (..))
import Distribution.Text ( display , simpleParse )
import System.FilePath ( (</>) )
#if MIN_VERSION_Cabal(1,25,0)
import Distribution.Simple.BuildPaths ( autogenComponentModulesDir )
#endif #endif
#if MIN_VERSION_directory(1,2,2) #if MIN_VERSION_cabal_doctest(1,0,0)
import System.Directory (makeAbsolute)
import Distribution.Extra.Doctest ( defaultMainWithDoctests )
main :: IO ()
main = defaultMainWithDoctests "doctests"
#else #else
import System.Directory (getCurrentDirectory)
import System.FilePath (isAbsolute)
makeAbsolute :: FilePath -> IO FilePath #ifdef MIN_VERSION_Cabal
makeAbsolute p | isAbsolute p = return p -- If the macro is defined, we have new cabal-install,
| otherwise = do -- but for some reason we don't have cabal-doctest in package-db
cwd <- getCurrentDirectory --
return $ cwd </> p -- Probably we are running cabal sdist, when otherwise using new-build
-- workflow
import Warning ()
#endif #endif
import Distribution.Simple
main :: IO () main :: IO ()
main = defaultMainWithHooks simpleUserHooks main = defaultMain
{ buildHook = \pkg lbi hooks flags -> do
generateBuildModule flags pkg lbi
buildHook simpleUserHooks pkg lbi hooks flags
}
generateBuildModule :: BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
generateBuildModule flags pkg lbi = do
let verbosity = fromFlag (buildVerbosity flags)
let distPref = fromFlag (buildDistPref flags)
-- Package DBs
let dbStack = withPackageDB lbi ++ [ SpecificPackageDB $ distPref </> "package.conf.inplace" ]
let dbFlags = "-hide-all-packages" : packageDbArgs dbStack
withLibLBI pkg lbi $ \lib libcfg -> do
let libBI = libBuildInfo lib
-- modules
let modules = exposedModules lib ++ otherModules libBI
-- it seems that doctest is happy to take in module names, not actual files!
let module_sources = modules
-- We need the directory with library's cabal_macros.h!
#if MIN_VERSION_Cabal(1,25,0)
let libAutogenDir = autogenComponentModulesDir lbi libcfg
#else
let libAutogenDir = autogenModulesDir lbi
#endif #endif
-- Lib sources and includes
iArgs <- mapM (fmap ("-i"++) . makeAbsolute) $ libAutogenDir : hsSourceDirs libBI
includeArgs <- mapM (fmap ("-I"++) . makeAbsolute) $ includeDirs libBI
-- CPP includes, i.e. include cabal_macros.h
let cppFlags = map ("-optP"++) $
[ "-include", libAutogenDir ++ "/cabal_macros.h" ]
++ cppOptions libBI
-- Actually we need to check whether testName suite == "doctests"
-- pending https://github.com/haskell/cabal/pull/4229 getting into GHC HEAD tree
withTestLBI pkg lbi $ \suite suitecfg -> when (testName suite == "doctests") $ do
-- get and create autogen dir
#if MIN_VERSION_Cabal(1,25,0)
let testAutogenDir = autogenComponentModulesDir lbi suitecfg
#else
let testAutogenDir = autogenModulesDir lbi
#endif
createDirectoryIfMissingVerbose verbosity True testAutogenDir
-- write autogen'd file
rewriteFile (testAutogenDir </> "Build_doctests.hs") $ unlines
[ "module Build_doctests where"
, ""
-- -package-id etc. flags
, "pkgs :: [String]"
, "pkgs = " ++ (show $ formatDeps $ testDeps libcfg suitecfg)
, ""
, "flags :: [String]"
, "flags = " ++ show (iArgs ++ includeArgs ++ dbFlags ++ cppFlags)
, ""
, "module_sources :: [String]"
, "module_sources = " ++ show (map display module_sources)
]
where
-- we do this check in Setup, as then doctests don't need to depend on Cabal
isOldCompiler = maybe False id $ do
a <- simpleParse $ showCompilerId $ compiler lbi
b <- simpleParse "7.5"
return $ packageVersion (a :: PackageId) < b
formatDeps = map formatOne
formatOne (installedPkgId, pkgId)
-- The problem is how different cabal executables handle package databases
-- when doctests depend on the library
| packageId pkg == pkgId = "-package=" ++ display pkgId
| otherwise = "-package-id=" ++ display installedPkgId
-- From Distribution.Simple.Program.GHC
packageDbArgs :: [PackageDB] -> [String]
packageDbArgs | isOldCompiler = packageDbArgsConf
| otherwise = packageDbArgsDb
-- GHC <7.6 uses '-package-conf' instead of '-package-db'.
packageDbArgsConf :: [PackageDB] -> [String]
packageDbArgsConf dbstack = case dbstack of
(GlobalPackageDB:UserPackageDB:dbs) -> concatMap specific dbs
(GlobalPackageDB:dbs) -> ("-no-user-package-conf")
: concatMap specific dbs
_ -> ierror
where
specific (SpecificPackageDB db) = [ "-package-conf=" ++ db ]
specific _ = ierror
ierror = error $ "internal error: unexpected package db stack: "
++ show dbstack
-- GHC >= 7.6 uses the '-package-db' flag. See
-- https://ghc.haskell.org/trac/ghc/ticket/5977.
packageDbArgsDb :: [PackageDB] -> [String]
-- special cases to make arguments prettier in common scenarios
packageDbArgsDb dbstack = case dbstack of
(GlobalPackageDB:UserPackageDB:dbs)
| all isSpecific dbs -> concatMap single dbs
(GlobalPackageDB:dbs)
| all isSpecific dbs -> "-no-user-package-db"
: concatMap single dbs
dbs -> "-clear-package-db"
: concatMap single dbs
where
single (SpecificPackageDB db) = [ "-package-db=" ++ db ]
single GlobalPackageDB = [ "-global-package-db" ]
single UserPackageDB = [ "-user-package-db" ]
isSpecific (SpecificPackageDB _) = True
isSpecific _ = False
testDeps :: ComponentLocalBuildInfo -> ComponentLocalBuildInfo -> [(InstalledPackageId, PackageId)]
testDeps xs ys = nub $ componentPackageDeps xs ++ componentPackageDeps ys
\end{code} \end{code}

View file

@ -1,5 +1,5 @@
name: servant-server name: servant-server
version: 0.10 version: 0.11
synopsis: A family of combinators for defining webservices APIs and serving them synopsis: A family of combinators for defining webservices APIs and serving them
description: description:
A family of combinators for defining webservices APIs and serving them A family of combinators for defining webservices APIs and serving them
@ -33,7 +33,9 @@ source-repository head
custom-setup custom-setup
setup-depends: setup-depends:
Cabal >=1.14, base, filepath, directory base >= 4 && <5,
Cabal,
cabal-doctest >= 1.0.1 && <1.1
library library
exposed-modules: exposed-modules:
@ -64,7 +66,7 @@ library
, mtl >= 2 && < 2.3 , mtl >= 2 && < 2.3
, network >= 2.6 && < 2.7 , network >= 2.6 && < 2.7
, safe >= 0.3 && < 0.4 , safe >= 0.3 && < 0.4
, servant == 0.10.* , servant == 0.11.*
, split >= 0.2 && < 0.3 , split >= 0.2 && < 0.3
, string-conversions >= 0.3 && < 0.5 , string-conversions >= 0.3 && < 0.5
, system-filepath >= 0.4 && < 0.5 , system-filepath >= 0.4 && < 0.5
@ -159,4 +161,6 @@ test-suite doctests
buildable: True buildable: True
default-language: Haskell2010 default-language: Haskell2010
ghc-options: -Wall -threaded ghc-options: -Wall -threaded
if impl(ghc >= 8.2)
x-doctest-options: -fdiagnostics-color=never
include-dirs: include include-dirs: include

View file

@ -228,5 +228,7 @@ layoutWithContext p context =
-- --
-- $setup -- $setup
-- >>> :set -XDataKinds
-- >>> :set -XTypeOperators
-- >>> import Servant.API -- >>> import Servant.API
-- >>> import Servant.Server -- >>> import Servant.Server

View file

@ -0,0 +1,25 @@
-----------------------------------------------------------------------------
-- |
-- Module : Main (doctests)
-- Copyright : (C) 2012-14 Edward Kmett
-- License : BSD-style (see the file LICENSE)
-- Maintainer : Edward Kmett <ekmett@gmail.com>
-- Stability : provisional
-- Portability : portable
--
-- This module provides doctests for a project based on the actual versions
-- of the packages it was built with. It requires a corresponding Setup.lhs
-- to be added to the project
-----------------------------------------------------------------------------
module Main where
import Build_doctests (flags, pkgs, module_sources)
import Data.Foldable (traverse_)
import Test.DocTest
main :: IO ()
main = do
traverse_ putStrLn args
doctest args
where
args = flags ++ pkgs ++ module_sources

View file

@ -1,61 +0,0 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE ForeignFunctionInterface #-}
-----------------------------------------------------------------------------
-- |
-- Module : Main (doctests)
-- Copyright : (C) 2012-14 Edward Kmett
-- License : BSD-style (see the file LICENSE)
-- Maintainer : Edward Kmett <ekmett@gmail.com>
-- Stability : provisional
-- Portability : portable
--
-- This module provides doctests for a project based on the actual versions
-- of the packages it was built with. It requires a corresponding Setup.lhs
-- to be added to the project
-----------------------------------------------------------------------------
module Main where
import Build_doctests (flags, pkgs, module_sources)
import Data.Foldable (traverse_)
import Test.DocTest
##if defined(mingw32_HOST_OS)
##if defined(i386_HOST_ARCH)
##define USE_CP
import Control.Applicative
import Control.Exception
import Foreign.C.Types
foreign import stdcall "windows.h SetConsoleCP" c_SetConsoleCP :: CUInt -> IO Bool
foreign import stdcall "windows.h GetConsoleCP" c_GetConsoleCP :: IO CUInt
##elif defined(x86_64_HOST_ARCH)
##define USE_CP
import Control.Applicative
import Control.Exception
import Foreign.C.Types
foreign import ccall "windows.h SetConsoleCP" c_SetConsoleCP :: CUInt -> IO Bool
foreign import ccall "windows.h GetConsoleCP" c_GetConsoleCP :: IO CUInt
##endif
##endif
-- | Run in a modified codepage where we can print UTF-8 values on Windows.
withUnicode :: IO a -> IO a
##ifdef USE_CP
withUnicode m = do
cp <- c_GetConsoleCP
(c_SetConsoleCP 65001 >> m) `finally` c_SetConsoleCP cp
##else
withUnicode m = m
##endif
main :: IO ()
main = withUnicode $ do
traverse_ putStrLn args
doctest args
where
args =
"-XOverloadedStrings" :
"-XFlexibleInstances" :
"-XMultiParamTypeClasses" :
"-XDataKinds" :
"-XTypeOperators" :
flags ++ pkgs ++ module_sources

View file

@ -1,5 +1,35 @@
0.11
----
### Breaking changes
- `Enter` refactored
([#734](https://github.com/haskell-servant/servant/issues/734)
, [#736](https://github.com/haskell-servant/servant/pull/736))
### Other changes
- Add a type representing an empty API
([#753](https://github.com/haskell-servant/servant/pull/753))
- Add `linkURI'` and `Link` accessors
([#745](https://github.com/haskell-servant/servant/pull/745)
, [#717](https://github.com/haskell-servant/servant/pull/717)
, [#715](https://github.com/haskell-servant/servant/issues/715))
- Prepare for GHC-8.2
([#722](https://github.com/haskell-servant/servant/pull/722))
- Add `HasLink AuthProtect` instance
([#720](https://github.com/haskell-servant/servant/pull/720))
- `AllCTRender [] ()` `TypeError` (use `NoContent`)
([#671](https://github.com/haskell-servant/servant/pull/671))
- Documentation improvements and typo fixes
([#702](https://github.com/haskell-servant/servant/pull/702)
, [#709](https://github.com/haskell-servant/servant/pull/709)
, [#716](https://github.com/haskell-servant/servant/pull/716)
, [#725](https://github.com/haskell-servant/servant/pull/725)
, [#727](https://github.com/haskell-servant/servant/pull/727))
0.10 0.10
------ ----
### Breaking changes ### Breaking changes

View file

@ -1,165 +1,34 @@
\begin{code} \begin{code}
{-# LANGUAGE CPP #-} {-# LANGUAGE CPP #-}
#ifndef MIN_VERSION_Cabal {-# OPTIONS_GHC -Wall #-}
#define MIN_VERSION_Cabal(x,y,z) 0
#endif
#ifndef MIN_VERSION_directory
#define MIN_VERSION_directory(x,y,z) 0
#endif
#if MIN_VERSION_Cabal(1,24,0)
#define InstalledPackageId UnitId
#endif
module Main (main) where module Main (main) where
import Control.Monad ( when ) #ifndef MIN_VERSION_cabal_doctest
import Data.List ( nub ) #define MIN_VERSION_cabal_doctest(x,y,z) 0
import Distribution.Package ( InstalledPackageId )
import Distribution.Package ( PackageId, Package (..), packageVersion )
import Distribution.PackageDescription ( PackageDescription(), TestSuite(..) , Library (..), BuildInfo (..))
import Distribution.Simple ( defaultMainWithHooks, UserHooks(..), simpleUserHooks )
import Distribution.Simple.Utils ( rewriteFile, createDirectoryIfMissingVerbose )
import Distribution.Simple.BuildPaths ( autogenModulesDir )
import Distribution.Simple.Setup ( BuildFlags(buildDistPref, buildVerbosity), fromFlag)
import Distribution.Simple.LocalBuildInfo ( withPackageDB, withLibLBI, withTestLBI, LocalBuildInfo(), ComponentLocalBuildInfo(componentPackageDeps), compiler )
import Distribution.Simple.Compiler ( showCompilerId , PackageDB (..))
import Distribution.Text ( display , simpleParse )
import System.FilePath ( (</>) )
#if MIN_VERSION_Cabal(1,25,0)
import Distribution.Simple.BuildPaths ( autogenComponentModulesDir )
#endif #endif
#if MIN_VERSION_directory(1,2,2) #if MIN_VERSION_cabal_doctest(1,0,0)
import System.Directory (makeAbsolute)
import Distribution.Extra.Doctest ( defaultMainWithDoctests )
main :: IO ()
main = defaultMainWithDoctests "doctests"
#else #else
import System.Directory (getCurrentDirectory)
import System.FilePath (isAbsolute)
makeAbsolute :: FilePath -> IO FilePath #ifdef MIN_VERSION_Cabal
makeAbsolute p | isAbsolute p = return p -- If the macro is defined, we have new cabal-install,
| otherwise = do -- but for some reason we don't have cabal-doctest in package-db
cwd <- getCurrentDirectory --
return $ cwd </> p -- Probably we are running cabal sdist, when otherwise using new-build
-- workflow
import Warning ()
#endif #endif
import Distribution.Simple
main :: IO () main :: IO ()
main = defaultMainWithHooks simpleUserHooks main = defaultMain
{ buildHook = \pkg lbi hooks flags -> do
generateBuildModule flags pkg lbi
buildHook simpleUserHooks pkg lbi hooks flags
}
generateBuildModule :: BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
generateBuildModule flags pkg lbi = do
let verbosity = fromFlag (buildVerbosity flags)
let distPref = fromFlag (buildDistPref flags)
-- Package DBs
let dbStack = withPackageDB lbi ++ [ SpecificPackageDB $ distPref </> "package.conf.inplace" ]
let dbFlags = "-hide-all-packages" : packageDbArgs dbStack
withLibLBI pkg lbi $ \lib libcfg -> do
let libBI = libBuildInfo lib
-- modules
let modules = exposedModules lib ++ otherModules libBI
-- it seems that doctest is happy to take in module names, not actual files!
let module_sources = modules
-- We need the directory with library's cabal_macros.h!
#if MIN_VERSION_Cabal(1,25,0)
let libAutogenDir = autogenComponentModulesDir lbi libcfg
#else
let libAutogenDir = autogenModulesDir lbi
#endif #endif
-- Lib sources and includes
iArgs <- mapM (fmap ("-i"++) . makeAbsolute) $ "test" : libAutogenDir : hsSourceDirs libBI
includeArgs <- mapM (fmap ("-I"++) . makeAbsolute) $ includeDirs libBI
-- CPP includes, i.e. include cabal_macros.h
let cppFlags = map ("-optP"++) $
[ "-include", libAutogenDir ++ "/cabal_macros.h" ]
++ cppOptions libBI
-- Actually we need to check whether testName suite == "doctests"
-- pending https://github.com/haskell/cabal/pull/4229 getting into GHC HEAD tree
withTestLBI pkg lbi $ \suite suitecfg -> when (testName suite == "doctests") $ do
-- get and create autogen dir
#if MIN_VERSION_Cabal(1,25,0)
let testAutogenDir = autogenComponentModulesDir lbi suitecfg
#else
let testAutogenDir = autogenModulesDir lbi
#endif
createDirectoryIfMissingVerbose verbosity True testAutogenDir
-- write autogen'd file
rewriteFile (testAutogenDir </> "Build_doctests.hs") $ unlines
[ "module Build_doctests where"
, ""
-- -package-id etc. flags
, "pkgs :: [String]"
, "pkgs = " ++ (show $ formatDeps $ testDeps libcfg suitecfg)
, ""
, "flags :: [String]"
, "flags = " ++ show (iArgs ++ includeArgs ++ dbFlags ++ cppFlags)
, ""
, "module_sources :: [String]"
, "module_sources = " ++ show ("Servant.Utils.LinksSpec" : map display module_sources)
]
where
-- we do this check in Setup, as then doctests don't need to depend on Cabal
isOldCompiler = maybe False id $ do
a <- simpleParse $ showCompilerId $ compiler lbi
b <- simpleParse "7.5"
return $ packageVersion (a :: PackageId) < b
formatDeps = map formatOne
formatOne (installedPkgId, pkgId)
-- The problem is how different cabal executables handle package databases
-- when doctests depend on the library
| packageId pkg == pkgId = "-package=" ++ display pkgId
| otherwise = "-package-id=" ++ display installedPkgId
-- From Distribution.Simple.Program.GHC
packageDbArgs :: [PackageDB] -> [String]
packageDbArgs | isOldCompiler = packageDbArgsConf
| otherwise = packageDbArgsDb
-- GHC <7.6 uses '-package-conf' instead of '-package-db'.
packageDbArgsConf :: [PackageDB] -> [String]
packageDbArgsConf dbstack = case dbstack of
(GlobalPackageDB:UserPackageDB:dbs) -> concatMap specific dbs
(GlobalPackageDB:dbs) -> ("-no-user-package-conf")
: concatMap specific dbs
_ -> ierror
where
specific (SpecificPackageDB db) = [ "-package-conf=" ++ db ]
specific _ = ierror
ierror = error $ "internal error: unexpected package db stack: "
++ show dbstack
-- GHC >= 7.6 uses the '-package-db' flag. See
-- https://ghc.haskell.org/trac/ghc/ticket/5977.
packageDbArgsDb :: [PackageDB] -> [String]
-- special cases to make arguments prettier in common scenarios
packageDbArgsDb dbstack = case dbstack of
(GlobalPackageDB:UserPackageDB:dbs)
| all isSpecific dbs -> concatMap single dbs
(GlobalPackageDB:dbs)
| all isSpecific dbs -> "-no-user-package-db"
: concatMap single dbs
dbs -> "-clear-package-db"
: concatMap single dbs
where
single (SpecificPackageDB db) = [ "-package-db=" ++ db ]
single GlobalPackageDB = [ "-global-package-db" ]
single UserPackageDB = [ "-user-package-db" ]
isSpecific (SpecificPackageDB _) = True
isSpecific _ = False
testDeps :: ComponentLocalBuildInfo -> ComponentLocalBuildInfo -> [(InstalledPackageId, PackageId)]
testDeps xs ys = nub $ componentPackageDeps xs ++ componentPackageDeps ys
\end{code} \end{code}

View file

@ -1,5 +1,5 @@
name: servant name: servant
version: 0.10 version: 0.11
synopsis: A family of combinators for defining webservices APIs synopsis: A family of combinators for defining webservices APIs
description: description:
A family of combinators for defining webservices APIs and serving them A family of combinators for defining webservices APIs and serving them
@ -27,7 +27,9 @@ source-repository head
custom-setup custom-setup
setup-depends: setup-depends:
Cabal >=1.14, base, filepath, directory base >= 4 && <5,
Cabal,
cabal-doctest >= 1.0.2 && <1.1
library library
exposed-modules: exposed-modules:
@ -147,5 +149,8 @@ test-suite doctests
buildable: True buildable: True
default-language: Haskell2010 default-language: Haskell2010
ghc-options: -Wall -threaded ghc-options: -Wall -threaded
build-tools: hsc2hs if impl(ghc >= 8.2)
x-doctest-options: -fdiagnostics-color=never
include-dirs: include include-dirs: include
x-doctest-source-dirs: test
x-doctest-modules: Servant.Utils.LinksSpec

View file

@ -419,6 +419,9 @@ instance MimeUnrender OctetStream BS.ByteString where
-- $setup -- $setup
-- >>> :set -XFlexibleInstances
-- >>> :set -XMultiParamTypeClasses
-- >>> :set -XOverloadedStrings
-- >>> import Servant.API -- >>> import Servant.API
-- >>> import Data.Aeson -- >>> import Data.Aeson
-- >>> import Data.Text -- >>> import Data.Text

25
servant/test/doctests.hs Normal file
View file

@ -0,0 +1,25 @@
-----------------------------------------------------------------------------
-- |
-- Module : Main (doctests)
-- Copyright : (C) 2012-14 Edward Kmett
-- License : BSD-style (see the file LICENSE)
-- Maintainer : Edward Kmett <ekmett@gmail.com>
-- Stability : provisional
-- Portability : portable
--
-- This module provides doctests for a project based on the actual versions
-- of the packages it was built with. It requires a corresponding Setup.lhs
-- to be added to the project
-----------------------------------------------------------------------------
module Main where
import Build_doctests (flags, pkgs, module_sources)
import Data.Foldable (traverse_)
import Test.DocTest
main :: IO ()
main = do
traverse_ putStrLn args
doctest args
where
args = flags ++ pkgs ++ module_sources

View file

@ -1,59 +0,0 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE ForeignFunctionInterface #-}
-----------------------------------------------------------------------------
-- |
-- Module : Main (doctests)
-- Copyright : (C) 2012-14 Edward Kmett
-- License : BSD-style (see the file LICENSE)
-- Maintainer : Edward Kmett <ekmett@gmail.com>
-- Stability : provisional
-- Portability : portable
--
-- This module provides doctests for a project based on the actual versions
-- of the packages it was built with. It requires a corresponding Setup.lhs
-- to be added to the project
-----------------------------------------------------------------------------
module Main where
import Build_doctests (flags, pkgs, module_sources)
import Data.Foldable (traverse_)
import Test.DocTest
##if defined(mingw32_HOST_OS)
##if defined(i386_HOST_ARCH)
##define USE_CP
import Control.Applicative
import Control.Exception
import Foreign.C.Types
foreign import stdcall "windows.h SetConsoleCP" c_SetConsoleCP :: CUInt -> IO Bool
foreign import stdcall "windows.h GetConsoleCP" c_GetConsoleCP :: IO CUInt
##elif defined(x86_64_HOST_ARCH)
##define USE_CP
import Control.Applicative
import Control.Exception
import Foreign.C.Types
foreign import ccall "windows.h SetConsoleCP" c_SetConsoleCP :: CUInt -> IO Bool
foreign import ccall "windows.h GetConsoleCP" c_GetConsoleCP :: IO CUInt
##endif
##endif
-- | Run in a modified codepage where we can print UTF-8 values on Windows.
withUnicode :: IO a -> IO a
##ifdef USE_CP
withUnicode m = do
cp <- c_GetConsoleCP
(c_SetConsoleCP 65001 >> m) `finally` c_SetConsoleCP cp
##else
withUnicode m = m
##endif
main :: IO ()
main = withUnicode $ do
traverse_ putStrLn args
doctest args
where
args =
"-XOverloadedStrings" :
"-XFlexibleInstances" :
"-XMultiParamTypeClasses" :
flags ++ pkgs ++ module_sources

20
stack-ghc-7.10.3.yaml Normal file
View file

@ -0,0 +1,20 @@
flags: {}
packages:
- servant/
- servant-client/
- servant-docs/
- servant-foreign/
- servant-server/
- doc/tutorial
extra-deps:
- attoparsec-iso8601-1.0.0.0
- cabal-doctest-1.0.2
- hspec-2.3.2
- hspec-core-2.3.2
- hspec-discover-2.3.2
- hspec-expectations-0.8.2
- hspec-wai-0.8.0
- http-api-data-0.3.7
- natural-transformation-0.4
- servant-js-0.9.3
resolver: lts-6.27

View file

@ -8,18 +8,20 @@ packages:
extra-deps: extra-deps:
- aeson-compat-0.3.6 - aeson-compat-0.3.6
- base-compat-0.9.1 - base-compat-0.9.1
- cabal-doctest-1.0.2
- call-stack-0.1.0
- control-monad-omega-0.3.1 - control-monad-omega-0.3.1
- cryptonite-0.6 - cryptonite-0.6
- doctest-0.11.0 - doctest-0.11.0
- hspec-2.3.2 - hspec-2.3.2
- hspec-discover-2.3.2
- hspec-core-2.3.2 - hspec-core-2.3.2
- hspec-wai-0.8.0 - hspec-discover-2.3.2
- hspec-expectations-0.8.2 - hspec-expectations-0.8.2
- call-stack-0.1.0 - hspec-wai-0.8.0
- http-api-data-0.3.6 - http-api-data-0.3.6
- natural-transformation-0.4 - natural-transformation-0.4
- primitive-0.6.1.0 - primitive-0.6.1.0
- servant-js-0.9.3
- should-not-typecheck-2.1.0 - should-not-typecheck-2.1.0
- time-locale-compat-0.1.1.1 - time-locale-compat-0.1.1.1
- uri-bytestring-0.2.2.0 - uri-bytestring-0.2.2.0

View file

@ -1,12 +0,0 @@
resolver: nightly-2017-04-01
packages:
- servant/
- servant-client/
- servant-docs/
- servant-foreign/
- servant-server/
- doc/tutorial
extra-deps:
- aeson-1.2.0.0
- attoparsec-iso8601-1.0.0.0
- http-api-data-0.3.7

View file

@ -1,4 +1,4 @@
flags: {} resolver: nightly-2017-04-01
packages: packages:
- servant/ - servant/
- servant-client/ - servant-client/
@ -7,13 +7,8 @@ packages:
- servant-server/ - servant-server/
- doc/tutorial - doc/tutorial
extra-deps: extra-deps:
- aeson-1.2.0.0
- attoparsec-iso8601-1.0.0.0 - attoparsec-iso8601-1.0.0.0
- cabal-doctest-1.0.2
- http-api-data-0.3.7 - http-api-data-0.3.7
- servant-js-0.9.1 - servant-js-0.9.3
- natural-transformation-0.4
- hspec-2.3.2
- hspec-discover-2.3.2
- hspec-core-2.3.2
- hspec-wai-0.8.0
- hspec-expectations-0.8.2
resolver: lts-6.27