git.iko.soy/typeable/hjsonschema
on master help sign in
0.7.1. See changelog.txt.
commit050514c54f0b126b3e8cf691a6366c2baa96e66b authorIan Grant Jeffries <ian@housejeffries.com> dateTue 20 Oct 2015, 10:21 (11 years ago) parent924cd08
7 files changed+104−5
.travis.yml+81 Example.hs+1 changelog.txt+4 hjsonschema.cabal+3−1 src/Data/JsonSchema.hs+7−2 src/Data/JsonSchema/Core.hs+5−2 src/Data/JsonSchema/Draft4/Any.hs+3
.travis.ymlnew file+81
@@ -0,0 +1,81 @@
1+# This file has been generated -- see https://github.com/hvr/multi-ghc-travis
2+#
3+# Manually modified to remove cabal check. I don't want a description field.
4+
5+language: c
6+sudo: false
7+
8+cache:
9+ directories:
10+ - $HOME/.cabsnap
11+ - $HOME/.cabal/packages
12+
13+before_cache:
14+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
15+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.tar
16+
17+matrix:
18+ include:
19+ - env: CABALVER=1.18 GHCVER=7.8.4
20+ compiler: ": #GHC 7.8.4"
21+ addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4], sources: [hvr-ghc]}}
22+ - env: CABALVER=1.22 GHCVER=7.10.2
23+ compiler: ": #GHC 7.10.2"
24+ addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.2], sources: [hvr-ghc]}}
25+
26+before_install:
27+ - unset CC
28+ - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
29+
30+install:
31+ - cabal --version
32+ - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
33+ - if [ -f $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz ];
34+ then
35+ zcat $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz >
36+ $HOME/.cabal/packages/hackage.haskell.org/00-index.tar;
37+ fi
38+ - travis_retry cabal update -v
39+ - sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
40+ - cabal install --only-dependencies --enable-tests --enable-benchmarks --dry -v > installplan.txt
41+ - sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt
42+
43+# check whether current requested install-plan matches cached package-db snapshot
44+ - if diff -u installplan.txt $HOME/.cabsnap/installplan.txt;
45+ then
46+ echo "cabal build-cache HIT";
47+ rm -rfv .ghc;
48+ cp -a $HOME/.cabsnap/ghc $HOME/.ghc;
49+ cp -a $HOME/.cabsnap/lib $HOME/.cabsnap/share $HOME/.cabsnap/bin $HOME/.cabal/;
50+ else
51+ echo "cabal build-cache MISS";
52+ rm -rf $HOME/.cabsnap;
53+ mkdir -p $HOME/.ghc $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin;
54+ cabal install --only-dependencies --enable-tests --enable-benchmarks;
55+ fi
56+
57+# snapshot package-db on cache miss
58+ - if [ ! -d $HOME/.cabsnap ];
59+ then
60+ echo "snapshotting package-db to build-cache";
61+ mkdir $HOME/.cabsnap;
62+ cp -a $HOME/.ghc $HOME/.cabsnap/ghc;
63+ cp -a $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin installplan.txt $HOME/.cabsnap/;
64+ fi
65+
66+# Here starts the actual work to be performed for the package under test;
67+# any command which exits with a non-zero exit code causes the build to fail.
68+script:
69+ - if [ -f configure.ac ]; then autoreconf -i; fi
70+ - cabal configure --enable-tests --enable-benchmarks -v2 # -v2 provides useful information for debugging
71+ - cabal build # this builds all libraries and executables (including tests/benchmarks)
72+ - cabal test
73+ - cabal sdist # tests that a source-distribution can be generated
74+
75+# Check that the resulting source distribution can be built & installed.
76+# If there are no other `.tar.gz` files in `dist`, this can be even simpler:
77+# `cabal install --force-reinstalls dist/*-*.tar.gz`
78+ - SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz &&
79+ (cd dist && cabal install --force-reinstalls "$SRC_TGZ")
80+
81+# EOF
Example.hs+1
@@ -2,6 +2,7 @@
22
33module Main where
44
5+import Control.Applicative
56import Data.Aeson
67import Data.HashMap.Strict (HashMap)
78import qualified Data.HashMap.Strict as H
changelog.txt+4
@@ -1,3 +1,7 @@
1+# 0.7.1
2+
3++ Support GHC 7.8 again.
4+
15# 0.7
26
37Change error type from Text to ValidationFailure.
hjsonschema.cabal+3−1
@@ -9,6 +9,7 @@ maintainer: ian@housejeffries.com
99category: Data
1010build-type: Simple
1111cabal-version: >=1.10
12+tested-with: GHC == 7.8.4, GHC == 7.10.2
1213extra-source-files: changelog.txt
1314 draft4.json
1415 JSON-Schema-Test-Suite/tests/draft4/*.json
@@ -35,7 +36,8 @@ library
3536 other-extensions: TemplateHaskell
3637 ghc-options: -Wall
3738 build-depends: aeson >= 0.7 && < 0.10
38− , base >= 4.6 && < 4.9
39+ -- 4.6 doesn't have a Traversable Either instance:
40+ , base >= 4.7 && < 4.9
3941 , bytestring >= 0.10 && < 0.11
4042 , containers >= 0.5 && < 0.6
4143 , file-embed >= 0.0.8 && < 0.0.10
src/Data/JsonSchema.hs+7−2
@@ -8,7 +8,8 @@ module Data.JsonSchema
88 , module Data.JsonSchema.Draft4
99 ) where
1010
11−import Control.Monad.Except
11+
12+import Control.Monad.Except (MonadError, MonadIO, join, throwError)
1213import qualified Data.ByteString.Lazy as LBS
1314import Data.Foldable
1415import qualified Data.HashMap.Strict as H
@@ -22,6 +23,9 @@ import qualified Data.JsonSchema.Helpers as HE
2223import Data.JsonSchema.Reference
2324import Import
2425
26+-- For GHCs before 7.10:
27+import Prelude hiding (sequence)
28+
2529-- | Take a schema. Retrieve every document either it or its
2630-- subschemas include via the "$ref" keyword. Load a 'Graph' out
2731-- with them.
@@ -34,7 +38,8 @@ fetchReferencedSchemas = fetchReferencedSchemas' HE.defaultFetch
3438-- is provided by the user. This allows restrictions to be added, e.g. rejecting
3539-- non-local URLs.
3640fetchReferencedSchemas'
37− :: forall t e m err. (IsString t, MonadError t e, Traversable e, MonadIO m)
41+ -- The `Functor m` declaration is for GHCs before 7.10.
42+ :: forall m e t err. (MonadIO m, Functor m, MonadError t e, Traversable e, IsString t)
3843 => (Text -> m (e LBS.ByteString))
3944 -> Spec err
4045 -> RawSchema
src/Data/JsonSchema/Core.hs+5−2
@@ -8,6 +8,9 @@ import Data.Maybe
88import Data.JsonSchema.Reference
99import Import
1010
11+-- For GHCs before 7.10:
12+import Prelude hiding (concat, sequence)
13+
1114--------------------------------------------------
1215-- * Primary API
1316--------------------------------------------------
@@ -73,9 +76,9 @@ type ValidatorConstructor schemaErr valErr
7376data ValidationFailure err = ValidationFailure
7477 { _failureName :: err
7578 , _failureInfo :: FailureInfo
76− } deriving (Show, Read)
79+ } deriving (Show)
7780
7881data FailureInfo = FailureInfo
7982 { _validatingData :: Value
8083 , _offendingData :: Value
81− } deriving (Show, Read)
84+ } deriving (Show)
src/Data/JsonSchema/Draft4/Any.hs+3
@@ -14,6 +14,9 @@ import Data.JsonSchema.Helpers
1414import Data.JsonSchema.Reference
1515import Import
1616
17+-- For GHCs before 7.10:
18+import Prelude hiding (any)
19+
1720-- | http://json-schema.org/latest/json-schema-validation.html#anchor76
1821--
1922-- > The value of this keyword MUST be an array.