Skip to content

Commit

Permalink
Merge pull request #26 from imalsogreg/split-core
Browse files Browse the repository at this point in the history
Split into core and server-side packages.
  • Loading branch information
imalsogreg authored Jun 4, 2018
2 parents b65a1c8 + 699c86f commit 8ee3a0f
Show file tree
Hide file tree
Showing 39 changed files with 787 additions and 129 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ cabal.sandbox.config
*.hp
*.eventlog
.stack-work/
*.nix
105 changes: 86 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
# This is the complex Travis configuration, which is intended for use
# on open source libraries which need compatibility across multiple GHC
# versions, must work with cabal-install, and should be
# cross-platform. For more information and other options, see:
#
# https://docs.haskellstack.org/en/stable/travis_ci/
#
# Copy these contents into the root directory of your Github project in a file
# named .travis.yml

# Use new container infrastructure to enable caching
sudo: false

# Choose a lightweight base image; we provide our own build tools.
language: c
# Do not choose a language; we provide our own build tools.
language: generic

# Caching so the next build will be fast too.
cache:
directories:
- $HOME/.ghc
- $HOME/.cabal
- $HOME/.stack
- $TRAVIS_BUILD_DIR/.stack-work

# The different configurations we want to test. We have BUILD=cabal which uses
# cabal-install, and BUILD=stack which uses Stack. More documentation on each
Expand All @@ -29,14 +37,32 @@ matrix:
# are finished building. Don't wait for the "allowed_failures" to finish.
fast_finish: true
include:
# We grab the appropriate GHC and cabal-install versions from hvr's PPA. See:
# https://github.com/hvr/multi-ghc-travis
#- env: BUILD=cabal GHCVER=7.0.4 CABALVER=1.16 HAPPYVER=1.19.5 ALEXVER=3.1.7
# compiler: ": #GHC 7.0.4"
# addons: {apt: {packages: [cabal-install-1.16,ghc-7.0.4,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
#- env: BUILD=cabal GHCVER=7.2.2 CABALVER=1.16 HAPPYVER=1.19.5 ALEXVER=3.1.7
# compiler: ": #GHC 7.2.2"
# addons: {apt: {packages: [cabal-install-1.16,ghc-7.2.2,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
#- env: BUILD=cabal GHCVER=7.4.2 CABALVER=1.16 HAPPYVER=1.19.5 ALEXVER=3.1.7
# compiler: ": #GHC 7.4.2"
# addons: {apt: {packages: [cabal-install-1.16,ghc-7.4.2,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
#- env: BUILD=cabal GHCVER=7.6.3 CABALVER=1.16 HAPPYVER=1.19.5 ALEXVER=3.1.7
# compiler: ": #GHC 7.6.3"
# addons: {apt: {packages: [cabal-install-1.16,ghc-7.6.3,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
#- env: BUILD=cabal GHCVER=7.8.4 CABALVER=1.18 HAPPYVER=1.19.5 ALEXVER=3.1.7
# compiler: ": #GHC 7.8.4"
# addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
#- env: BUILD=cabal GHCVER=7.10.3 CABALVER=1.22 HAPPYVER=1.19.5 ALEXVER=3.1.7
# compiler: ": #GHC 7.10.3"
# addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
- env: BUILD=cabal GHCVER=8.0.2 CABALVER=1.24 HAPPYVER=1.19.5 ALEXVER=3.1.7
compiler: ": #GHC 8.0.2"
addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.2,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}

- env: BUILD=cabal GHCVER=8.2.2 CABALVER=2.0 HAPPYVER=1.19.5 ALEXVER=3.1.7
compiler: ": #GHC 8.2.2"
addons: {apt: {packages: [cabal-install-2.0,ghc-8.2.2,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}

- env: BUILD=cabal GHCVER=8.4.1 CABALVER=2.0 HAPPYVER=1.19.5 ALEXVER=3.1.7
compiler: ": #GHC 8.4.1"
addons: {apt: {packages: [cabal-install-2.0,ghc-8.4.1,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
Expand All @@ -47,25 +73,67 @@ matrix:
compiler: ": #GHC HEAD"
addons: {apt: {packages: [cabal-install-head,ghc-head,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}

# The Stack LTS builds.

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

#- env: BUILD=stack ARGS="--resolver lts-2"
# compiler: ": #stack 7.8.4"
# addons: {apt: {packages: [libgmp-dev]}}

#- env: BUILD=stack ARGS="--resolver lts-3"
# compiler: ": #stack 7.10.2"
# addons: {apt: {packages: [libgmp-dev]}}

#- env: BUILD=stack ARGS="--resolver lts-6"
# compiler: ": #stack 7.10.3"
# addons: {apt: {packages: [libgmp-dev]}}

#- env: BUILD=stack ARGS="--resolver lts-7"
# compiler: ": #stack 8.0.1"
# addons: {apt: {packages: [libgmp-dev]}}

# - env: BUILD=stack ARGS="--resolver lts-9"
# compiler: ": #stack 8.0.2"
# addons: {apt: {packages: [libgmp-dev]}}

- env: BUILD=stack ARGS="--resolver lts-11"
compiler: ": #stack 8.2.2"
addons: {apt: {packages: [libgmp-dev]}}


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

# Build on OS X with Stack in addition to Linux.
# Build on macOS in addition to Linux
- env: BUILD=stack ARGS=""
compiler: ": #stack default osx"
os: osx

# Travis includes an macOS which is incompatible with GHC 7.8.4
#- env: BUILD=stack ARGS="--resolver lts-2"
# compiler: ": #stack 7.8.4 osx"
# os: osx

#- env: BUILD=stack ARGS="--resolver lts-3"
# compiler: ": #stack 7.10.2 osx"
# os: osx

#- env: BUILD=stack ARGS="--resolver lts-6"
# compiler: ": #stack 7.10.3 osx"
# os: osx

#- env: BUILD=stack ARGS="--resolver lts-7"
# compiler: ": #stack 8.0.1 osx"
# os: osx

# - env: BUILD=stack ARGS="--resolver lts-9"
# compiler: ": #stack 8.0.2 osx"
# os: osx

- env: BUILD=stack ARGS="--resolver lts-11"
compiler: ": #stack 8.2.2 osx"
os: osx
Expand All @@ -75,8 +143,8 @@ matrix:
os: osx

allow_failures:
- env: BUILD=stack ARGS="--resolver nightly"
- env: BUILD=cabal GHCVER=head CABALVER=head HAPPYVER=1.19.5 ALEXVER=3.1.7
- env: BUILD=stack ARGS="--resolver nightly"
- os: osx

before_install:
Expand All @@ -93,20 +161,16 @@ before_install:
- |
if [ `uname` = "Darwin" ]
then
travis_retry curl --insecure -L https://www.stackage.org/stack/osx-x86_64 | tar xz --strip-components=1 --include '*/stack' -C ~/.local/bin
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
else
travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
travis_retry curl -L https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
fi
# Use the more reliable S3 mirror of Hackage
mkdir -p $HOME/.cabal
echo 'remote-repo: hackage.haskell.org:http://hackage.fpcomplete.com/' > $HOME/.cabal/config
echo 'remote-repo-cache: $HOME/.cabal/packages' >> $HOME/.cabal/config
if [ "$CABALVER" != "1.16" ]
then
echo 'jobs: $ncpus' >> $HOME/.cabal/config
fi
install:
- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
Expand Down Expand Up @@ -160,10 +224,13 @@ script:
cd "$PKGVER"
cabal configure --enable-tests --ghc-options -O0 --flags="buildexample"
cabal build
cabal test
if [ "$CABALVER" = "1.16" ] || [ "$CABALVER" = "1.18" ]; then
cabal test
else
cabal test --show-details=streaming --log=/dev/stdout
fi
cd $ORIGDIR
done
;;
esac
set +ex
15 changes: 0 additions & 15 deletions CHANGELOG.md

This file was deleted.

10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,13 @@ search api:
```

You can see that both the success and error responses are documented.

## Packaging the core types

[`servant-checked-exceptions-core`](https://hackage.haskell.org/package/servant-checked-exceptions-core)
exports the core types need for building an API with checked exceptions,
allowing you to avoid depending on server-side libraries like `warp`, `Glob`
and `servant-server`. This can be useful if you are writing an API meant to be
shared with ghcjs and run in a browser, where these dependencies aren't
available.

1 change: 1 addition & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: servant-checked-exceptions-core/* servant-checked-exceptions/*
11 changes: 11 additions & 0 deletions servant-checked-exceptions-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## 2.0.0.0

* Initial release of `servant-checked-exceptions-core` package, with
core types factored out of `servant-checked-exceptions` for users
who want access to them without incurring a dependency on `servant-server`
and `servant-client`. See
[issue 25](https://github.com/cdepillabout/servant-checked-exceptions/issues/25)

* Compared to `servant-checked-exceptions`, `servant-checked-exceptions-core`
breaks up the `Exceptions` module into `Verbs` and `Envelope`.
[issue 18](https://github.com/cdepillabout/servant-checked-exceptions/issues/18)
30 changes: 30 additions & 0 deletions servant-checked-exceptions-core/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Copyright Dennis Gosnell (c) 2017

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.

* Neither the name of Author name here nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1 change: 1 addition & 0 deletions servant-checked-exceptions-core/README.md
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: servant-checked-exceptions-core
version: 2.0.0.0
synopsis: Checked exceptions for Servant APIs.
description: Please see <https://github.com/cdepillabout/servant-checked-exceptions#readme README.md>.
homepage: https://github.com/cdepillabout/servant-checked-exceptions
license: BSD3
license-file: LICENSE
author: Dennis Gosnell
maintainer: [email protected]
copyright: 2017-2018 Dennis Gosnell
category: Text
build-type: Simple
extra-source-files: CHANGELOG.md
, README.md
cabal-version: >=1.10

flag buildexample
description: Build a small example program
default: False

library
hs-source-dirs: src
exposed-modules: Servant.Checked.Exceptions
, Servant.Checked.Exceptions.Envelope
, Servant.Checked.Exceptions.Verbs
, Servant.Checked.Exceptions.Internal
, Servant.Checked.Exceptions.Internal.Envelope
, Servant.Checked.Exceptions.Internal.Prism
, Servant.Checked.Exceptions.Internal.Servant
, Servant.Checked.Exceptions.Internal.Servant.API
, Servant.Checked.Exceptions.Internal.Servant.Docs
, Servant.Checked.Exceptions.Internal.Util
, Servant.Checked.Exceptions.Internal.Verbs
build-depends: base >= 4.9 && < 5
, aeson
, bytestring
, deepseq
, http-media
, http-types
, profunctors
, tagged
, servant >= 0.12
, servant-docs >= 0.10
, text
, world-peace
default-language: Haskell2010
ghc-options: -Wall -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -fwarn-monomorphism-restriction
other-extensions: QuasiQuotes
, TemplateHaskell

executable servant-checked-exceptions-example-docs
main-is: Docs.hs
other-modules: Api
hs-source-dirs: example
build-depends: base
, aeson
, http-api-data
, http-types
, servant
, servant-checked-exceptions-core
, servant-docs
, text
default-language: Haskell2010
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N

if flag(buildexample)
buildable: True
else
buildable: False

test-suite servant-checked-exceptions-doctest
if impl(ghcjs)
buildable: False
type: exitcode-stdio-1.0
main-is: DocTest.hs
hs-source-dirs: test
build-depends: base
, doctest
, Glob
default-language: Haskell2010
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
source-repository head
type: git
location: [email protected]:cdepillabout/servant-checked-exceptions.git
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,13 @@ module Servant.Checked.Exceptions
-- combinators. It also exports the 'OpenProduct' type and 'ToProduct' type
-- class used by some of the functions above.
, module Data.WorldPeace
, module Servant.Checked.Exceptions.Internal.Servant.Docs
) where

import Data.WorldPeace
import Network.HTTP.Types (Status)

import Servant.Checked.Exceptions.Internal
import Servant.Checked.Exceptions.Internal.Envelope
import Servant.Checked.Exceptions.Internal.Servant.API
import Servant.Checked.Exceptions.Internal.Servant.Docs
import Servant.Checked.Exceptions.Internal.Verbs
Loading

0 comments on commit 8ee3a0f

Please sign in to comment.