Skip to content

Commit

Permalink
Merge pull request #6 from juspay/koz/qc
Browse files Browse the repository at this point in the history
Koz/qc
  • Loading branch information
kozross authored Aug 5, 2020
2 parents ca6bbd1 + c11a9b9 commit 6f57f7f
Show file tree
Hide file tree
Showing 13 changed files with 335 additions and 366 deletions.
33 changes: 0 additions & 33 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,36 +47,3 @@ jobs:
- name: Test
run: |
cabal test all --enable-tests --test-show-details=streaming
stack:
name: ${{ matrix.os }} stack / ghc ${{ matrix.ghc }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
stack: ["latest"]
ghc: ["8.6.5"]

steps:
- uses: actions/checkout@v2
if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master'

- uses: actions/[email protected]
name: Setup Haskell Stack
with:
ghc-version: ${{ matrix.ghc }}
stack-version: ${{ matrix.stack }}

- uses: actions/cache@v1
name: Cache ~/.stack
with:
path: ~/.stack
key: ${{ runner.os }}-${{ matrix.ghc }}-stack

- name: Build
run: |
stack build --system-ghc --test --no-run-tests
- name: Test
run: |
stack test --system-ghc
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Dev

# 1.2.0

- Widen QuickCheck bounds.
- Remove MonadError from the top-level API.
- Use strict, rather than lazy, bytestrings for parser input. This fixes issues
with resource safety.
- Test with GHC 8.8.4.
- Change `stack.yaml` to use LTS 15.15.

# 1.1.2

- Ship our .hspec file to ensure all tests pass from an sdist.
Expand Down
9 changes: 2 additions & 7 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ anyone, they should become issues or PRs, and be removed from this list.
`Value` (that is, the JSON chunk that failed).
* `WrongType` appears unused. This is either a mistake (and thus, it should be
used), or if it's no longer necessary, it should be removed wholesale.
* Given that the validator works in `MonadPlus`, it should collect all errors
(using something with efficient concatenation), or operate in `MonadLogic`.
* Loaders (and validators) from files or `Handle`s should employ the [bracket
pattern][bracket-pattern]. This is particularly pertinent to `Handle`s.
* `ConflictingSpecRequirements` currently gets thrown on two arguably quite
different conditions. This should be split into two different data
constructors, indicating each of them separately.
Expand All @@ -30,6 +26,5 @@ anyone, they should become issues or PRs, and be removed from this list.
elucidated or specified - this should happen.
* Figure out why our CI settings break on the following combinations:
* Cabal latest, Windows latest, GHC 8.8.3
* Stack latest, macOS latest, GHC 8.6.5

[bracket-pattern]: https://wiki.haskell.org/Bracket_pattern
* Checking custom schemata currently relies on an unsafe construction. This
should be replaced by a safer one.
5 changes: 2 additions & 3 deletions TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,20 +287,19 @@ is either a JSON boolean or the JSON ``null``.
To validate a JSON value using Medea from Haskell:

```Haskell
import Control.Monad.Trans.Except (runExcept, runExceptT)
import Data.Aeson (Value)
import Data.Medea.Loader (loadSchemaFromFile)
import Data.Medea (validate)

main :: IO ()
main = do
-- Compile a Medea schema graph from its file representation
result <- runExceptT . loadSchemaFromFile $ "./my-schema.medea"
result <- loadSchemaFromFile "./my-schema.medea"
case result of
Left e -> print e
Right scm -> do
-- Validate against the schema graph we just compiled
validation <- runExcept $ validate scm (myJson :: Value)
validation <- validate scm (myJson :: Value)
case validation of
Left e -> print e
Right _ -> putStrLn "JSON is valid against schema"
Expand Down
63 changes: 24 additions & 39 deletions medea.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.2
name: medea
version: 1.1.2
version: 1.2.0
synopsis: A schema language for JSON.
description:
A reference implementation of a schema language, together with a conformance
Expand All @@ -18,7 +18,7 @@ maintainer: [email protected]
copyright: Juspay Technologies Pvt Ltd (C) 2020
category: Data
build-type: Simple
tested-with: GHC ==8.6.5 || ==8.8.3 || ==8.10.1
tested-with: GHC ==8.6.5 || ==8.8.4 || ==8.10.1
extra-source-files:
CHANGELOG.md
README.md
Expand All @@ -37,12 +37,23 @@ source-repository head

common lang-common
default-language: Haskell2010
build-depends: base >=4.11.1 && <5
ghc-options:
-Wall -Wcompat -Wincomplete-record-updates
-Wincomplete-uni-patterns -Wredundant-constraints

common test-common
ghc-options: -threaded -with-rtsopts=-N
import: lang-common
other-modules: TestM
build-depends:
, directory ^>=1.3.3.0
, filepath ^>=1.4.2.1
, hspec ^>=2.7.1
, medea
, mtl

ghc-options: -threaded -with-rtsopts=-N
hs-source-dirs: test

library
import: lang-common
Expand All @@ -66,7 +77,6 @@ library
build-depends:
, aeson >=1.4.6.0 && <2.0.0.0
, algebraic-graphs ^>=0.5
, base >=4.11.1 && <5
, bytestring ^>=0.10.8.2
, containers ^>=0.6.0.1
, deepseq ^>=1.4.4.0
Expand All @@ -78,6 +88,7 @@ library
, nonempty-containers ^>=0.3.3.0
, parser-combinators >=1.1.0 && <2.0.0
, scientific ^>=0.3.6.2
, smash ^>=0.1.1.0
, text ^>=1.2.3.1
, unordered-containers ^>=0.2.10.0
, vector ^>=0.12.0.3
Expand All @@ -86,56 +97,30 @@ library
hs-source-dirs: src

test-suite conformance-parser
import: lang-common, test-common
import: test-common
type: exitcode-stdio-1.0
main-is: Main.hs
other-modules: TestM
build-depends:
, base
, directory ^>=1.3.3.0
, filepath ^>=1.4.2.1
, hspec ^>=2.7.1
, medea
, mtl

hs-source-dirs: test/parser test
hs-source-dirs: test/parser

test-suite conformance-schema-builder
import: lang-common, test-common
import: test-common
type: exitcode-stdio-1.0
main-is: Main.hs
other-modules: TestM
build-depends:
, base
, directory ^>=1.3.3.0
, filepath ^>=1.4.2.1
, hspec ^>=2.7.1
, medea
, mtl

hs-source-dirs: test/schema-builder test
hs-source-dirs: test/schema-builder

test-suite quickcheck-validator
import: lang-common, test-common
import: test-common
type: exitcode-stdio-1.0
main-is: Main.hs
other-modules:
Data.Aeson.Arbitrary
TestM

other-modules: Data.Aeson.Arbitrary
build-depends:
, aeson
, base
, directory ^>=1.3.3.0
, filepath ^>=1.4.2.1
, hspec ^>=2.7.1
, bytestring
, hspec-core ^>=2.7.1
, medea
, mtl
, QuickCheck ^>=2.13.2
, QuickCheck >=2.13.2 && <2.15.0
, quickcheck-instances ^>=0.3.22
, text
, unordered-containers ^>=0.2.10.0
, vector

hs-source-dirs: test/validator-quickcheck test
hs-source-dirs: test/validator-quickcheck
Loading

0 comments on commit 6f57f7f

Please sign in to comment.