Skip to content

Commit

Permalink
Upgrade stack LTS version and fix aeson problems
Browse files Browse the repository at this point in the history
This closes #5 and is related to sol#170

- Update with aeson 1 support
- Use LTS-8
  • Loading branch information
yamadapc committed May 12, 2017
1 parent a51e6ee commit 0993265
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 11 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ matrix:
- env: BUILD=stack GHCVER=7.10.3 STACK_YAML=stack.yaml
compiler: ": #stack 7.10.3"
addons: {apt: {packages: [ghc-7.10.3,happy-1.19.5], sources: [hvr-ghc]}}
- env: BUILD=stack GHCVER=7.10.3 STACK_YAML=stack-5.yaml
compiler: ": #stack 7.10.3"
addons: {apt: {packages: [ghc-7.10.3,happy-1.19.5], sources: [hvr-ghc]}}
- env: BUILD=stack STACK_YAML=stack.yaml
compiler: ": #stack 7.10.3 osx"
os: osx
- env: BUILD=stack STACK_YAML=stack.yaml
compiler: ": #stack 8.0.2"
addons: {apt: {packages: [cabal-install-1.22,ghc-8.0.2,happy-1.19.5], sources: [hvr-ghc]}}

before_install:
- unset CC
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
test: FORCE
stack build --stack-yaml ./stack-5.yaml
stack test --stack-yaml ./stack-5.yaml
stack build
stack test

docker-build:
for dockerfile in dockerfiles/*; do docker build -f $$dockerfile . ; done

Expand Down
10 changes: 5 additions & 5 deletions hpack-convert.cabal
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- This file has been generated from package.yaml by hpack version 0.14.0.
-- This file has been generated from package.yaml by hpack version 0.17.0.
--
-- see: https://github.com/sol/hpack

Expand Down Expand Up @@ -72,7 +72,7 @@ library
, yaml
, bytestring
, vector
, aeson == 0.11.*
, aeson
exposed-modules:
Hpack
Hpack.Convert
Expand Down Expand Up @@ -109,7 +109,7 @@ executable hpack-convert
, yaml
, bytestring
, vector
, aeson == 0.11.*
, aeson
, hpack-convert
default-language: Haskell2010

Expand All @@ -118,7 +118,7 @@ test-suite spec
main-is: Spec.hs
hs-source-dirs:
test
, src
src
ghc-options: -Wall -fcontext-stack=100
cpp-options: -DTEST
build-depends:
Expand All @@ -136,7 +136,7 @@ test-suite spec
, yaml
, bytestring
, vector
, aeson == 0.11.*
, aeson
, hspec == 2.*
, QuickCheck
, temporary
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies:
- yaml
- bytestring
- vector
- aeson == 0.11.*
- aeson

library:
source-dirs: src
Expand Down
23 changes: 22 additions & 1 deletion src/Hpack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ jsonOptions name = defaultOptions { fieldLabelModifier = hyphenize name
, omitNothingFields = True
}

#if MIN_VERSION_aeson(1,0,0)
genericToJSON_ :: forall a. (Generic a, GToJSON Zero (Rep a), HasTypeName a) => a -> Value
#else
genericToJSON_ :: forall a. (Generic a, GToJSON (Rep a), HasTypeName a) => a -> Value
#endif
genericToJSON_ =
removeEmptyObjects .
removeEmptyArrays .
Expand All @@ -135,7 +139,11 @@ removeEmptyArrays :: Value -> Value
removeEmptyArrays (Object o) = Object $ HashMap.filter (/= Array mempty) o
removeEmptyArrays v = v

#if MIN_VERSION_aeson(1,0,0)
genericParseJSON_ :: forall a. (Generic a, GFromJSON Zero (Rep a), HasTypeName a) => Value -> Parser a
#else
genericParseJSON_ :: forall a. (Generic a, GFromJSON (Rep a), HasTypeName a) => Value -> Parser a
#endif
genericParseJSON_ = genericParseJSON (jsonOptions name)
where
name :: String
Expand Down Expand Up @@ -451,7 +459,11 @@ mergeObjects (Object o1) _ = Object o1
mergeObjects _ (Object o2) = Object o2
mergeObjects v _ = v

instance ToJSON [Section Executable] where
#if __GLASGOW_HASKELL__ >= 710
instance {-# OVERLAPS #-} ToJSON [Section Executable] where
#else
instance ToJSON [Section Executable] where
#endif
toJSON ss = Object $
HashMap.fromList $ map helper ss
where
Expand Down Expand Up @@ -487,8 +499,13 @@ instance ToJSON (Section ()) where
s {sectionBuildable = Nothing}
omitRedundantBuildable s = s

#if MIN_VERSION_aeson(1,0,0)
instance (Generic (Section a), GToJSON Zero (Rep (Section a)), HasTypeName (Section a),
ToJSON a) => ToJSON (Section a) where
#else
instance (Generic (Section a), GToJSON (Rep (Section a)), HasTypeName (Section a),
ToJSON a) => ToJSON (Section a) where
#endif
toJSON sect@Section{..} =
omitBuildableTrue (omitSection
(mergeObjects
Expand Down Expand Up @@ -545,7 +562,11 @@ instance ToJSON Executable where
instance ToJSON Library where
toJSON = genericToJSON_

#if __GLASGOW_HASKELL__ >= 710
instance {-# OVERLAPS #-} ToJSON [Flag] where
#else
instance ToJSON [Flag] where
#endif
toJSON fs = Object $
HashMap.fromList $ map helper fs
where
Expand Down
7 changes: 7 additions & 0 deletions stack-5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
flags: {}
packages:
- '.'
extra-deps:
- aeson-0.11.0.0
- unordered-containers-0.2.7.1
resolver: lts-5.3
6 changes: 2 additions & 4 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
flags: {}
packages:
- '.'
extra-deps:
- aeson-0.11.0.0
- unordered-containers-0.2.7.1
resolver: lts-5.3
extra-deps: []
resolver: lts-8.13

0 comments on commit 0993265

Please sign in to comment.