From 3bc007813a2f6a75ff50a2f6d3a3a9f9e75bb9b5 Mon Sep 17 00:00:00 2001 From: "Michal J. Gajda" Date: Tue, 27 Nov 2018 20:14:48 +0100 Subject: [PATCH] Completed json-alt split. --- .gitlab-ci.yml | 26 ++++++++-- json-alt/json-alt.cabal | 15 +----- .../Data/Aeson/AutoType/Alternative.hs | 48 ------------------- json-autotype/{ => app}/GenerateJSONParser.hs | 0 json-autotype/changelog.md | 1 + json-autotype/{ => common}/CommonCLI.hs | 0 json-autotype/json-autotype.cabal | 33 +++++++------ .../{ => src}/Data/Aeson/AutoType/CodeGen.hs | 0 .../Data/Aeson/AutoType/CodeGen/Common.hs | 0 .../Data/Aeson/AutoType/CodeGen/Elm.hs | 0 .../Data/Aeson/AutoType/CodeGen/ElmFormat.hs | 0 .../Data/Aeson/AutoType/CodeGen/Generic.hs | 0 .../Data/Aeson/AutoType/CodeGen/Haskell.hs | 0 .../Aeson/AutoType/CodeGen/HaskellFormat.hs | 0 .../{ => src}/Data/Aeson/AutoType/Extract.hs | 0 .../{ => src}/Data/Aeson/AutoType/Format.hs | 0 .../Data/Aeson/AutoType/Plugin/Loader.hs | 0 .../Data/Aeson/AutoType/Plugin/Subtype.hs | 0 .../{ => src}/Data/Aeson/AutoType/Pretty.hs | 0 .../{ => src}/Data/Aeson/AutoType/Split.hs | 0 .../{ => src}/Data/Aeson/AutoType/Type.hs | 0 .../{ => src}/Data/Aeson/AutoType/Util.hs | 0 json-autotype/{ => test}/GenerateTestJSON.hs | 0 23 files changed, 43 insertions(+), 80 deletions(-) delete mode 100644 json-autotype/Data/Aeson/AutoType/Alternative.hs rename json-autotype/{ => app}/GenerateJSONParser.hs (100%) rename json-autotype/{ => common}/CommonCLI.hs (100%) rename json-autotype/{ => src}/Data/Aeson/AutoType/CodeGen.hs (100%) rename json-autotype/{ => src}/Data/Aeson/AutoType/CodeGen/Common.hs (100%) rename json-autotype/{ => src}/Data/Aeson/AutoType/CodeGen/Elm.hs (100%) rename json-autotype/{ => src}/Data/Aeson/AutoType/CodeGen/ElmFormat.hs (100%) rename json-autotype/{ => src}/Data/Aeson/AutoType/CodeGen/Generic.hs (100%) rename json-autotype/{ => src}/Data/Aeson/AutoType/CodeGen/Haskell.hs (100%) rename json-autotype/{ => src}/Data/Aeson/AutoType/CodeGen/HaskellFormat.hs (100%) rename json-autotype/{ => src}/Data/Aeson/AutoType/Extract.hs (100%) rename json-autotype/{ => src}/Data/Aeson/AutoType/Format.hs (100%) rename json-autotype/{ => src}/Data/Aeson/AutoType/Plugin/Loader.hs (100%) rename json-autotype/{ => src}/Data/Aeson/AutoType/Plugin/Subtype.hs (100%) rename json-autotype/{ => src}/Data/Aeson/AutoType/Pretty.hs (100%) rename json-autotype/{ => src}/Data/Aeson/AutoType/Split.hs (100%) rename json-autotype/{ => src}/Data/Aeson/AutoType/Type.hs (100%) rename json-autotype/{ => src}/Data/Aeson/AutoType/Util.hs (100%) rename json-autotype/{ => test}/GenerateTestJSON.hs (100%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ba42a58..c67d05c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,13 +18,18 @@ cache: - cabal --version - ghc --version - cabal update + - cd json-alt + - cabal install + - cabal sdist --builddir=../sdist/ + - cabal haddock --builddir=../hackage-docs/ --for-hackage + - cd ../json-autotype - "sed --in-place 's/-- STATIC: //' json-autotype.cabal" - cabal install --only-dependencies --enable-tests --enable-benchmarks - cabal test - mkdir -p bin sdist - - cabal install --bindir=bin/ - - cabal sdist --builddir=sdist/ - - cabal haddock --builddir hackage-docs --for-hackage + - cabal install --bindir=../bin/ + - cabal sdist --builddir=../sdist/ + - cabal haddock --builddir=../hackage-docs --for-hackage build_8_6_2: variables: @@ -32,6 +37,8 @@ build_8_6_2: extends: .build_exe artifacts: paths: + - sdist/json-alt-*[0-9].tar.gz + - hackage-docs/json-alt-*-docs.tar.gz - sdist/json-autotype-*[0-9].tar.gz - hackage-docs/json-autotype-*-docs.tar.gz - bin/json-autotype @@ -76,7 +83,7 @@ test_distribution: - build_8_6_2 artifacts: paths: - - bin/json-autotype + - json-autotype/bin/json-autotype stack_build: image: migamake/haskell-build:8.6.2 @@ -88,9 +95,20 @@ stack_build: - stack test allow_failure: true +pier_build: + image: migamake/haskell-build:8.6.2 + stage: build + script: + - pier --version + - pier build + - pier test + allow_failure: true + release_to_hackage: stage: release script: + - cabal upload --username="$HACKAGE_USER" --password="$HACKAGE_PASSWORD" sdist/json-alt-*[0-9].tar.gz + - cabal upload --username="$HACKAGE_USER" --password="$HACKAGE_PASSWORD" -d hackage-docs/json-alt-*-docs.tar.gz - cabal upload --username="$HACKAGE_USER" --password="$HACKAGE_PASSWORD" sdist/json-autotype-*[0-9].tar.gz - cabal upload --username="$HACKAGE_USER" --password="$HACKAGE_PASSWORD" -d hackage-docs/json-autotype-*-docs.tar.gz dependencies: diff --git a/json-alt/json-alt.cabal b/json-alt/json-alt.cabal index 422f7b0..8c6b358 100644 --- a/json-alt/json-alt.cabal +++ b/json-alt/json-alt.cabal @@ -73,18 +73,5 @@ library DeriveGeneric, RecordWildCards build-depends: base >=4.3 && <5, - GenericPretty >=1.2 && <1.3, - aeson >=1.2.1 && <1.5, - containers >=0.3 && <0.7, - filepath >=1.3 && <1.5, - hashable >=1.2 && <1.3, - lens >=4.1 && <4.18, - mtl >=2.1 && <2.3, - pretty >=1.1 && <1.3, - process >=1.1 && <1.7, - scientific >=0.3 && <0.5, - text >=1.1 && <1.4, - uniplate >=1.6 && <1.7, - unordered-containers >=0.2 && <0.3, - vector >=0.9 && <0.13 + aeson >=1.2.1 && <1.5 default-language: Haskell2010 diff --git a/json-autotype/Data/Aeson/AutoType/Alternative.hs b/json-autotype/Data/Aeson/AutoType/Alternative.hs deleted file mode 100644 index fa5e1e4..0000000 --- a/json-autotype/Data/Aeson/AutoType/Alternative.hs +++ /dev/null @@ -1,48 +0,0 @@ -{-# LANGUAGE TypeOperators #-} --- | This module defines data type (a :|: b) that behaves all like @Either@, --- except that has no tag in JSON representation as used by @FromJSON@ and @ToJSON@. -module Data.Aeson.AutoType.Alternative( - (:|:)(..) - , toEither, fromEither - , alt - ) where - -import Data.Aeson -import Control.Applicative - --- | Data type (a :|: b) that behaves all like @Either@, --- except that has no tag in JSON representation as used by @FromJSON@ and @ToJSON@. -data a :|: b = AltLeft a - | AltRight b - deriving(Show,Eq,Ord) -infixr 5 :|: - --- | Convert to @Either@ datatype. -toEither :: a :|: b -> Either a b -toEither (AltLeft a) = Left a -toEither (AltRight b) = Right b -{-# INLINE toEither #-} - --- | Convert from @Either@ datatype. -fromEither :: Either a b -> a :|: b -fromEither (Left a) = AltLeft a -fromEither (Right b) = AltRight b -{-# INLINE fromEither #-} - --- | Deconstruct the type with two functions corresponding to constructors. --- This is like @either@. -alt :: (a -> c) -> (b -> c) -> a :|: b -> c -alt f _ (AltLeft a) = f a -alt _ g (AltRight b) = g b -infixr 5 `alt` - -instance (ToJSON a, ToJSON b) => ToJSON (a :|: b) where - toJSON (AltLeft a) = toJSON a - toJSON (AltRight b) = toJSON b - {-# INLINE toJSON #-} - -instance (FromJSON a, FromJSON b) => FromJSON (a :|: b) where - parseJSON input = (AltLeft <$> parseJSON input) <|> - (AltRight <$> parseJSON input) <|> - fail ("Neither alternative was found for: " ++ show input) - {-# INLINE parseJSON #-} diff --git a/json-autotype/GenerateJSONParser.hs b/json-autotype/app/GenerateJSONParser.hs similarity index 100% rename from json-autotype/GenerateJSONParser.hs rename to json-autotype/app/GenerateJSONParser.hs diff --git a/json-autotype/changelog.md b/json-autotype/changelog.md index 5c2b847..781ad05 100644 --- a/json-autotype/changelog.md +++ b/json-autotype/changelog.md @@ -5,6 +5,7 @@ Changelog * Hide all API beside Alternative (as unused outside generator). * Add fixity for alt (#20) * Use `eitherDecode` instead of `decode` to get better error messages. + * Split Data.Aeson.AutoType.Alternative to `json-alt`. 2.0.2 Nov 2018 * Clean up the tests. diff --git a/json-autotype/CommonCLI.hs b/json-autotype/common/CommonCLI.hs similarity index 100% rename from json-autotype/CommonCLI.hs rename to json-autotype/common/CommonCLI.hs diff --git a/json-autotype/json-autotype.cabal b/json-autotype/json-autotype.cabal index 5c14daf..5a0b93a 100644 --- a/json-autotype/json-autotype.cabal +++ b/json-autotype/json-autotype.cabal @@ -64,20 +64,20 @@ source-repository head location: https://github.com/mgajda/json-autotype.git library - exposed-modules: Data.Aeson.AutoType.Alternative - Data.Aeson.AutoType.Pretty - Data.Aeson.AutoType.Type - Data.Aeson.AutoType.Test - Data.Aeson.AutoType.Extract - Data.Aeson.AutoType.Format - Data.Aeson.AutoType.Split - Data.Aeson.AutoType.CodeGen + exposed-modules: Data.Aeson.AutoType.CodeGen Data.Aeson.AutoType.CodeGen.Generic Data.Aeson.AutoType.CodeGen.Haskell Data.Aeson.AutoType.CodeGen.Elm Data.Aeson.AutoType.CodeGen.HaskellFormat Data.Aeson.AutoType.CodeGen.ElmFormat + Data.Aeson.AutoType.Extract + Data.Aeson.AutoType.Format + Data.Aeson.AutoType.Pretty + Data.Aeson.AutoType.Split + Data.Aeson.AutoType.Type + Data.Aeson.AutoType.Test Data.Aeson.AutoType.Util + hs-source-dirs: src other-extensions: TemplateHaskell, ScopedTypeVariables, @@ -102,11 +102,15 @@ library uniplate >=1.6 && <1.7, unordered-containers >=0.2 && <0.3, vector >=0.9 && <0.13, - json-alt + smallcheck >=1.0 && <1.2, + QuickCheck >=2.4 && <3.0, + json-alt, + template-haskell default-language: Haskell2010 executable json-autotype main-is: GenerateJSONParser.hs + hs-source-dirs: app common other-modules: CommonCLI Paths_json_autotype other-extensions: TemplateHaskell, @@ -147,7 +151,8 @@ executable json-autotype -- and extracted types. test-suite json-autotype-qc-test type: exitcode-stdio-1.0 - main-is: test/TestQC.hs + main-is: TestQC.hs + hs-source-dirs: test common other-extensions: TemplateHaskell, ScopedTypeVariables, OverloadedStrings, @@ -173,13 +178,13 @@ test-suite json-autotype-qc-test QuickCheck >=2.4 && <3.0, json-autotype, json-alt - -- hs-source-dirs: default-language: Haskell2010 test-suite json-autotype-examples type: exitcode-stdio-1.0 - main-is: test/TestExamples.hs + main-is: TestExamples.hs other-modules: CommonCLI + hs-source-dirs: test common other-extensions: TemplateHaskell, ScopedTypeVariables, @@ -217,7 +222,8 @@ test-suite json-autotype-examples test-suite json-autotype-gen-test type: exitcode-stdio-1.0 main-is: GenerateTestJSON.hs - other-modules: CommonCLI + hs-source-dirs: test common + other-modules: CommonCLI other-extensions: TemplateHaskell, ScopedTypeVariables, @@ -250,5 +256,4 @@ test-suite json-autotype-gen-test template-haskell, json-autotype, json-alt - -- hs-source-dirs: default-language: Haskell2010 diff --git a/json-autotype/Data/Aeson/AutoType/CodeGen.hs b/json-autotype/src/Data/Aeson/AutoType/CodeGen.hs similarity index 100% rename from json-autotype/Data/Aeson/AutoType/CodeGen.hs rename to json-autotype/src/Data/Aeson/AutoType/CodeGen.hs diff --git a/json-autotype/Data/Aeson/AutoType/CodeGen/Common.hs b/json-autotype/src/Data/Aeson/AutoType/CodeGen/Common.hs similarity index 100% rename from json-autotype/Data/Aeson/AutoType/CodeGen/Common.hs rename to json-autotype/src/Data/Aeson/AutoType/CodeGen/Common.hs diff --git a/json-autotype/Data/Aeson/AutoType/CodeGen/Elm.hs b/json-autotype/src/Data/Aeson/AutoType/CodeGen/Elm.hs similarity index 100% rename from json-autotype/Data/Aeson/AutoType/CodeGen/Elm.hs rename to json-autotype/src/Data/Aeson/AutoType/CodeGen/Elm.hs diff --git a/json-autotype/Data/Aeson/AutoType/CodeGen/ElmFormat.hs b/json-autotype/src/Data/Aeson/AutoType/CodeGen/ElmFormat.hs similarity index 100% rename from json-autotype/Data/Aeson/AutoType/CodeGen/ElmFormat.hs rename to json-autotype/src/Data/Aeson/AutoType/CodeGen/ElmFormat.hs diff --git a/json-autotype/Data/Aeson/AutoType/CodeGen/Generic.hs b/json-autotype/src/Data/Aeson/AutoType/CodeGen/Generic.hs similarity index 100% rename from json-autotype/Data/Aeson/AutoType/CodeGen/Generic.hs rename to json-autotype/src/Data/Aeson/AutoType/CodeGen/Generic.hs diff --git a/json-autotype/Data/Aeson/AutoType/CodeGen/Haskell.hs b/json-autotype/src/Data/Aeson/AutoType/CodeGen/Haskell.hs similarity index 100% rename from json-autotype/Data/Aeson/AutoType/CodeGen/Haskell.hs rename to json-autotype/src/Data/Aeson/AutoType/CodeGen/Haskell.hs diff --git a/json-autotype/Data/Aeson/AutoType/CodeGen/HaskellFormat.hs b/json-autotype/src/Data/Aeson/AutoType/CodeGen/HaskellFormat.hs similarity index 100% rename from json-autotype/Data/Aeson/AutoType/CodeGen/HaskellFormat.hs rename to json-autotype/src/Data/Aeson/AutoType/CodeGen/HaskellFormat.hs diff --git a/json-autotype/Data/Aeson/AutoType/Extract.hs b/json-autotype/src/Data/Aeson/AutoType/Extract.hs similarity index 100% rename from json-autotype/Data/Aeson/AutoType/Extract.hs rename to json-autotype/src/Data/Aeson/AutoType/Extract.hs diff --git a/json-autotype/Data/Aeson/AutoType/Format.hs b/json-autotype/src/Data/Aeson/AutoType/Format.hs similarity index 100% rename from json-autotype/Data/Aeson/AutoType/Format.hs rename to json-autotype/src/Data/Aeson/AutoType/Format.hs diff --git a/json-autotype/Data/Aeson/AutoType/Plugin/Loader.hs b/json-autotype/src/Data/Aeson/AutoType/Plugin/Loader.hs similarity index 100% rename from json-autotype/Data/Aeson/AutoType/Plugin/Loader.hs rename to json-autotype/src/Data/Aeson/AutoType/Plugin/Loader.hs diff --git a/json-autotype/Data/Aeson/AutoType/Plugin/Subtype.hs b/json-autotype/src/Data/Aeson/AutoType/Plugin/Subtype.hs similarity index 100% rename from json-autotype/Data/Aeson/AutoType/Plugin/Subtype.hs rename to json-autotype/src/Data/Aeson/AutoType/Plugin/Subtype.hs diff --git a/json-autotype/Data/Aeson/AutoType/Pretty.hs b/json-autotype/src/Data/Aeson/AutoType/Pretty.hs similarity index 100% rename from json-autotype/Data/Aeson/AutoType/Pretty.hs rename to json-autotype/src/Data/Aeson/AutoType/Pretty.hs diff --git a/json-autotype/Data/Aeson/AutoType/Split.hs b/json-autotype/src/Data/Aeson/AutoType/Split.hs similarity index 100% rename from json-autotype/Data/Aeson/AutoType/Split.hs rename to json-autotype/src/Data/Aeson/AutoType/Split.hs diff --git a/json-autotype/Data/Aeson/AutoType/Type.hs b/json-autotype/src/Data/Aeson/AutoType/Type.hs similarity index 100% rename from json-autotype/Data/Aeson/AutoType/Type.hs rename to json-autotype/src/Data/Aeson/AutoType/Type.hs diff --git a/json-autotype/Data/Aeson/AutoType/Util.hs b/json-autotype/src/Data/Aeson/AutoType/Util.hs similarity index 100% rename from json-autotype/Data/Aeson/AutoType/Util.hs rename to json-autotype/src/Data/Aeson/AutoType/Util.hs diff --git a/json-autotype/GenerateTestJSON.hs b/json-autotype/test/GenerateTestJSON.hs similarity index 100% rename from json-autotype/GenerateTestJSON.hs rename to json-autotype/test/GenerateTestJSON.hs