Skip to content

Commit 699c86f

Browse files
committed
Split into servant-checked-exceptions and -core
- Split out servant-checked-exceptions-core and build with ghc/ghcjs - Split out servant-checked-exceptions serverside package and test with ghc - Shuffle documentation - Bump version number and CHANGELOGs - Updating the travis config to the latest version.
1 parent b65a1c8 commit 699c86f

39 files changed

+787
-129
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ cabal.sandbox.config
1616
*.hp
1717
*.eventlog
1818
.stack-work/
19+
*.nix

.travis.yml

Lines changed: 86 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
1+
# This is the complex Travis configuration, which is intended for use
2+
# on open source libraries which need compatibility across multiple GHC
3+
# versions, must work with cabal-install, and should be
4+
# cross-platform. For more information and other options, see:
5+
#
6+
# https://docs.haskellstack.org/en/stable/travis_ci/
7+
#
18
# Copy these contents into the root directory of your Github project in a file
29
# named .travis.yml
310

411
# Use new container infrastructure to enable caching
512
sudo: false
613

7-
# Choose a lightweight base image; we provide our own build tools.
8-
language: c
14+
# Do not choose a language; we provide our own build tools.
15+
language: generic
916

1017
# Caching so the next build will be fast too.
1118
cache:
1219
directories:
1320
- $HOME/.ghc
1421
- $HOME/.cabal
1522
- $HOME/.stack
23+
- $TRAVIS_BUILD_DIR/.stack-work
1624

1725
# The different configurations we want to test. We have BUILD=cabal which uses
1826
# cabal-install, and BUILD=stack which uses Stack. More documentation on each
@@ -29,14 +37,32 @@ matrix:
2937
# are finished building. Don't wait for the "allowed_failures" to finish.
3038
fast_finish: true
3139
include:
40+
# We grab the appropriate GHC and cabal-install versions from hvr's PPA. See:
41+
# https://github.com/hvr/multi-ghc-travis
42+
#- env: BUILD=cabal GHCVER=7.0.4 CABALVER=1.16 HAPPYVER=1.19.5 ALEXVER=3.1.7
43+
# compiler: ": #GHC 7.0.4"
44+
# addons: {apt: {packages: [cabal-install-1.16,ghc-7.0.4,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
45+
#- env: BUILD=cabal GHCVER=7.2.2 CABALVER=1.16 HAPPYVER=1.19.5 ALEXVER=3.1.7
46+
# compiler: ": #GHC 7.2.2"
47+
# addons: {apt: {packages: [cabal-install-1.16,ghc-7.2.2,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
48+
#- env: BUILD=cabal GHCVER=7.4.2 CABALVER=1.16 HAPPYVER=1.19.5 ALEXVER=3.1.7
49+
# compiler: ": #GHC 7.4.2"
50+
# addons: {apt: {packages: [cabal-install-1.16,ghc-7.4.2,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
51+
#- env: BUILD=cabal GHCVER=7.6.3 CABALVER=1.16 HAPPYVER=1.19.5 ALEXVER=3.1.7
52+
# compiler: ": #GHC 7.6.3"
53+
# addons: {apt: {packages: [cabal-install-1.16,ghc-7.6.3,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
54+
#- env: BUILD=cabal GHCVER=7.8.4 CABALVER=1.18 HAPPYVER=1.19.5 ALEXVER=3.1.7
55+
# compiler: ": #GHC 7.8.4"
56+
# addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
57+
#- env: BUILD=cabal GHCVER=7.10.3 CABALVER=1.22 HAPPYVER=1.19.5 ALEXVER=3.1.7
58+
# compiler: ": #GHC 7.10.3"
59+
# addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
3260
- env: BUILD=cabal GHCVER=8.0.2 CABALVER=1.24 HAPPYVER=1.19.5 ALEXVER=3.1.7
3361
compiler: ": #GHC 8.0.2"
3462
addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.2,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
35-
3663
- env: BUILD=cabal GHCVER=8.2.2 CABALVER=2.0 HAPPYVER=1.19.5 ALEXVER=3.1.7
3764
compiler: ": #GHC 8.2.2"
3865
addons: {apt: {packages: [cabal-install-2.0,ghc-8.2.2,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
39-
4066
- env: BUILD=cabal GHCVER=8.4.1 CABALVER=2.0 HAPPYVER=1.19.5 ALEXVER=3.1.7
4167
compiler: ": #GHC 8.4.1"
4268
addons: {apt: {packages: [cabal-install-2.0,ghc-8.4.1,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
@@ -47,25 +73,67 @@ matrix:
4773
compiler: ": #GHC HEAD"
4874
addons: {apt: {packages: [cabal-install-head,ghc-head,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
4975

50-
# The Stack LTS builds.
51-
52-
# Build using the configuration specified in the stack.yaml file in the
53-
# current directory.
76+
# The Stack builds. We can pass in arbitrary Stack arguments via the ARGS
77+
# variable, such as using --stack-yaml to point to a different file.
5478
- env: BUILD=stack ARGS=""
5579
compiler: ": #stack default"
5680
addons: {apt: {packages: [libgmp-dev]}}
5781

82+
#- env: BUILD=stack ARGS="--resolver lts-2"
83+
# compiler: ": #stack 7.8.4"
84+
# addons: {apt: {packages: [libgmp-dev]}}
85+
86+
#- env: BUILD=stack ARGS="--resolver lts-3"
87+
# compiler: ": #stack 7.10.2"
88+
# addons: {apt: {packages: [libgmp-dev]}}
89+
90+
#- env: BUILD=stack ARGS="--resolver lts-6"
91+
# compiler: ": #stack 7.10.3"
92+
# addons: {apt: {packages: [libgmp-dev]}}
93+
94+
#- env: BUILD=stack ARGS="--resolver lts-7"
95+
# compiler: ": #stack 8.0.1"
96+
# addons: {apt: {packages: [libgmp-dev]}}
97+
98+
# - env: BUILD=stack ARGS="--resolver lts-9"
99+
# compiler: ": #stack 8.0.2"
100+
# addons: {apt: {packages: [libgmp-dev]}}
101+
58102
- env: BUILD=stack ARGS="--resolver lts-11"
59103
compiler: ": #stack 8.2.2"
60104
addons: {apt: {packages: [libgmp-dev]}}
61105

62-
63106
# Nightly builds are allowed to fail
64107
- env: BUILD=stack ARGS="--resolver nightly"
65108
compiler: ": #stack nightly"
66109
addons: {apt: {packages: [libgmp-dev]}}
67110

68-
# Build on OS X with Stack in addition to Linux.
111+
# Build on macOS in addition to Linux
112+
- env: BUILD=stack ARGS=""
113+
compiler: ": #stack default osx"
114+
os: osx
115+
116+
# Travis includes an macOS which is incompatible with GHC 7.8.4
117+
#- env: BUILD=stack ARGS="--resolver lts-2"
118+
# compiler: ": #stack 7.8.4 osx"
119+
# os: osx
120+
121+
#- env: BUILD=stack ARGS="--resolver lts-3"
122+
# compiler: ": #stack 7.10.2 osx"
123+
# os: osx
124+
125+
#- env: BUILD=stack ARGS="--resolver lts-6"
126+
# compiler: ": #stack 7.10.3 osx"
127+
# os: osx
128+
129+
#- env: BUILD=stack ARGS="--resolver lts-7"
130+
# compiler: ": #stack 8.0.1 osx"
131+
# os: osx
132+
133+
# - env: BUILD=stack ARGS="--resolver lts-9"
134+
# compiler: ": #stack 8.0.2 osx"
135+
# os: osx
136+
69137
- env: BUILD=stack ARGS="--resolver lts-11"
70138
compiler: ": #stack 8.2.2 osx"
71139
os: osx
@@ -75,8 +143,8 @@ matrix:
75143
os: osx
76144

77145
allow_failures:
78-
- env: BUILD=stack ARGS="--resolver nightly"
79146
- env: BUILD=cabal GHCVER=head CABALVER=head HAPPYVER=1.19.5 ALEXVER=3.1.7
147+
- env: BUILD=stack ARGS="--resolver nightly"
80148
- os: osx
81149

82150
before_install:
@@ -93,20 +161,16 @@ before_install:
93161
- |
94162
if [ `uname` = "Darwin" ]
95163
then
96-
travis_retry curl --insecure -L https://www.stackage.org/stack/osx-x86_64 | tar xz --strip-components=1 --include '*/stack' -C ~/.local/bin
164+
travis_retry curl --insecure -L https://get.haskellstack.org/stable/osx-x86_64.tar.gz | tar xz --strip-components=1 --include '*/stack' -C ~/.local/bin
97165
else
98-
travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
166+
travis_retry curl -L https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
99167
fi
100168
101169
# Use the more reliable S3 mirror of Hackage
102170
mkdir -p $HOME/.cabal
103171
echo 'remote-repo: hackage.haskell.org:http://hackage.fpcomplete.com/' > $HOME/.cabal/config
104172
echo 'remote-repo-cache: $HOME/.cabal/packages' >> $HOME/.cabal/config
105173
106-
if [ "$CABALVER" != "1.16" ]
107-
then
108-
echo 'jobs: $ncpus' >> $HOME/.cabal/config
109-
fi
110174
111175
install:
112176
- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
@@ -160,10 +224,13 @@ script:
160224
cd "$PKGVER"
161225
cabal configure --enable-tests --ghc-options -O0 --flags="buildexample"
162226
cabal build
163-
cabal test
227+
if [ "$CABALVER" = "1.16" ] || [ "$CABALVER" = "1.18" ]; then
228+
cabal test
229+
else
230+
cabal test --show-details=streaming --log=/dev/stdout
231+
fi
164232
cd $ORIGDIR
165233
done
166234
;;
167235
esac
168236
set +ex
169-

CHANGELOG.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,13 @@ search api:
210210
```
211211

212212
You can see that both the success and error responses are documented.
213+
214+
## Packaging the core types
215+
216+
[`servant-checked-exceptions-core`](https://hackage.haskell.org/package/servant-checked-exceptions-core)
217+
exports the core types need for building an API with checked exceptions,
218+
allowing you to avoid depending on server-side libraries like `warp`, `Glob`
219+
and `servant-server`. This can be useful if you are writing an API meant to be
220+
shared with ghcjs and run in a browser, where these dependencies aren't
221+
available.
222+

cabal.project

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: servant-checked-exceptions-core/* servant-checked-exceptions/*
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## 2.0.0.0
2+
3+
* Initial release of `servant-checked-exceptions-core` package, with
4+
core types factored out of `servant-checked-exceptions` for users
5+
who want access to them without incurring a dependency on `servant-server`
6+
and `servant-client`. See
7+
[issue 25](https://github.com/cdepillabout/servant-checked-exceptions/issues/25)
8+
9+
* Compared to `servant-checked-exceptions`, `servant-checked-exceptions-core`
10+
breaks up the `Exceptions` module into `Verbs` and `Envelope`.
11+
[issue 18](https://github.com/cdepillabout/servant-checked-exceptions/issues/18)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Copyright Dennis Gosnell (c) 2017
2+
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
11+
* Redistributions in binary form must reproduce the above
12+
copyright notice, this list of conditions and the following
13+
disclaimer in the documentation and/or other materials provided
14+
with the distribution.
15+
16+
* Neither the name of Author name here nor the names of other
17+
contributors may be used to endorse or promote products derived
18+
from this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../README.md
File renamed without changes.
File renamed without changes.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: servant-checked-exceptions-core
2+
version: 2.0.0.0
3+
synopsis: Checked exceptions for Servant APIs.
4+
description: Please see <https://github.com/cdepillabout/servant-checked-exceptions#readme README.md>.
5+
homepage: https://github.com/cdepillabout/servant-checked-exceptions
6+
license: BSD3
7+
license-file: LICENSE
8+
author: Dennis Gosnell
9+
maintainer: [email protected]
10+
copyright: 2017-2018 Dennis Gosnell
11+
category: Text
12+
build-type: Simple
13+
extra-source-files: CHANGELOG.md
14+
, README.md
15+
cabal-version: >=1.10
16+
17+
flag buildexample
18+
description: Build a small example program
19+
default: False
20+
21+
library
22+
hs-source-dirs: src
23+
exposed-modules: Servant.Checked.Exceptions
24+
, Servant.Checked.Exceptions.Envelope
25+
, Servant.Checked.Exceptions.Verbs
26+
, Servant.Checked.Exceptions.Internal
27+
, Servant.Checked.Exceptions.Internal.Envelope
28+
, Servant.Checked.Exceptions.Internal.Prism
29+
, Servant.Checked.Exceptions.Internal.Servant
30+
, Servant.Checked.Exceptions.Internal.Servant.API
31+
, Servant.Checked.Exceptions.Internal.Servant.Docs
32+
, Servant.Checked.Exceptions.Internal.Util
33+
, Servant.Checked.Exceptions.Internal.Verbs
34+
build-depends: base >= 4.9 && < 5
35+
, aeson
36+
, bytestring
37+
, deepseq
38+
, http-media
39+
, http-types
40+
, profunctors
41+
, tagged
42+
, servant >= 0.12
43+
, servant-docs >= 0.10
44+
, text
45+
, world-peace
46+
default-language: Haskell2010
47+
ghc-options: -Wall -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -fwarn-monomorphism-restriction
48+
other-extensions: QuasiQuotes
49+
, TemplateHaskell
50+
51+
executable servant-checked-exceptions-example-docs
52+
main-is: Docs.hs
53+
other-modules: Api
54+
hs-source-dirs: example
55+
build-depends: base
56+
, aeson
57+
, http-api-data
58+
, http-types
59+
, servant
60+
, servant-checked-exceptions-core
61+
, servant-docs
62+
, text
63+
default-language: Haskell2010
64+
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
65+
66+
if flag(buildexample)
67+
buildable: True
68+
else
69+
buildable: False
70+
71+
test-suite servant-checked-exceptions-doctest
72+
if impl(ghcjs)
73+
buildable: False
74+
type: exitcode-stdio-1.0
75+
main-is: DocTest.hs
76+
hs-source-dirs: test
77+
build-depends: base
78+
, doctest
79+
, Glob
80+
default-language: Haskell2010
81+
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
82+
source-repository head
83+
type: git
84+
location: [email protected]:cdepillabout/servant-checked-exceptions.git

src/Servant/Checked/Exceptions.hs renamed to servant-checked-exceptions-core/src/Servant/Checked/Exceptions.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,13 @@ module Servant.Checked.Exceptions
165165
-- combinators. It also exports the 'OpenProduct' type and 'ToProduct' type
166166
-- class used by some of the functions above.
167167
, module Data.WorldPeace
168+
, module Servant.Checked.Exceptions.Internal.Servant.Docs
168169
) where
169170

170171
import Data.WorldPeace
171172
import Network.HTTP.Types (Status)
172173

173-
import Servant.Checked.Exceptions.Internal
174+
import Servant.Checked.Exceptions.Internal.Envelope
175+
import Servant.Checked.Exceptions.Internal.Servant.API
176+
import Servant.Checked.Exceptions.Internal.Servant.Docs
177+
import Servant.Checked.Exceptions.Internal.Verbs

0 commit comments

Comments
 (0)