Skip to content

Compatibility with Stackage Nightly #935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions aeson.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ library
bytestring >= 0.10.4.0 && < 0.12,
containers >= 0.5.5.1 && < 0.7,
deepseq >= 1.3.0.0 && < 1.5,
ghc-prim >= 0.2 && < 0.8,
template-haskell >= 2.9.0.0 && < 2.18,
ghc-prim >= 0.2 && < 0.9,
template-haskell >= 2.9.0.0 && < 2.19,
text >= 1.2.3.0 && < 1.3,
time >= 1.4 && < 1.12

Expand Down Expand Up @@ -132,7 +132,7 @@ library
attoparsec >= 0.13.2.2 && < 0.15,
data-fix >= 0.3 && < 0.4,
dlist >= 0.8.0.4 && < 1.1,
hashable >= 1.2.7.0 && < 1.4,
hashable >= 1.2.7.0 && < 1.5,
primitive >= 0.7.0.1 && < 0.8,
scientific >= 0.3.7.0 && < 0.4,
strict >= 0.4 && < 0.5,
Expand Down
3 changes: 2 additions & 1 deletion src/Data/Aeson/Encoding/Builder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ import Prelude.Compat

import Data.Aeson.Internal.Time
import Data.Aeson.Types.Internal (Value (..))
import Data.ByteString.Builder as B
import qualified Data.ByteString.Builder as B
import Data.ByteString.Builder (Builder)
import Data.ByteString.Builder.Prim as BP
import Data.ByteString.Builder.Scientific (scientificBuilder)
import Data.Char (chr, ord)
Expand Down
4 changes: 1 addition & 3 deletions stack-nightly.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: nightly-2019-10-14
resolver: nightly-2022-03-22
packages:
- '.'
- attoparsec-iso8601
Expand All @@ -7,5 +7,3 @@ flags:
fast: true
attoparsec-iso8601:
fast: true
extra-deps:
- generic-deriving-1.12.4
3 changes: 2 additions & 1 deletion tests/Encoders.hs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ gFooParseJSONRejectUnknownFieldsTagged = genericParseJSON optsRejectUnknownField
-- Option fields
--------------------------------------------------------------------------------

#if !MIN_VERSION_base(4,16,0)
thOptionFieldToJSON :: OptionField -> Value
thOptionFieldToJSON = $(mkToJSON optsOptionField 'OptionField)

Expand All @@ -292,7 +293,7 @@ gOptionFieldParseJSON = genericParseJSON optsOptionField

thMaybeFieldToJSON :: MaybeField -> Value
thMaybeFieldToJSON = $(mkToJSON optsOptionField 'MaybeField)

#endif

--------------------------------------------------------------------------------
-- IncoherentInstancesNeeded
Expand Down
3 changes: 3 additions & 0 deletions tests/Instances.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
Expand Down Expand Up @@ -153,8 +154,10 @@ instance Arbitrary EitherTextInt where
instance Arbitrary (GADT String) where
arbitrary = GADT <$> arbitrary

#if !MIN_VERSION_base(4,16,0)
instance Arbitrary OptionField where
arbitrary = OptionField <$> arbitrary
#endif


instance ApproxEq Char where
Expand Down
6 changes: 6 additions & 0 deletions tests/PropertyGeneric.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ module PropertyGeneric ( genericTests ) where

import Prelude.Compat

#if !MIN_VERSION_base(4,16,0)
import Data.Semigroup (Option(..))
#endif
import Encoders
import Instances ()
import Test.Tasty (TestTree, testGroup)
Expand Down Expand Up @@ -57,11 +59,13 @@ genericTests =
, testProperty "Tagged" (toParseJSON gOneConstructorParseJSONTagged gOneConstructorToJSONTagged)
]
]
#if !MIN_VERSION_base(4,16,0)
, testGroup "OptionField" [
testProperty "like Maybe" $
\x -> gOptionFieldToJSON (OptionField (Option x)) === thMaybeFieldToJSON (MaybeField x)
, testProperty "roundTrip" (toParseJSON gOptionFieldParseJSON gOptionFieldToJSON)
]
#endif
]
, testGroup "toEncoding" [
testProperty "NullaryString" $
Expand Down Expand Up @@ -110,7 +114,9 @@ genericTests =
, testProperty "OneConstructorTagged" $
gOneConstructorToJSONTagged `sameAs` gOneConstructorToEncodingTagged

#if !MIN_VERSION_base(4,16,0)
, testProperty "OptionField" $
gOptionFieldToJSON `sameAs` gOptionFieldToEncoding
#endif
]
]
7 changes: 7 additions & 0 deletions tests/PropertyTH.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE NoImplicitPrelude #-}

module PropertyTH ( templateHaskellTests ) where

import Prelude.Compat

#if !MIN_VERSION_base(4,16,0)
import Data.Semigroup (Option(..))
#endif
import Encoders
import Instances ()
import Test.Tasty (TestTree, testGroup)
Expand Down Expand Up @@ -74,11 +77,13 @@ templateHaskellTests =
, testProperty "Tagged" (toParseJSON thOneConstructorParseJSONTagged thOneConstructorToJSONTagged)
]
]
#if !MIN_VERSION_base(4,16,0)
, testGroup "OptionField" [
testProperty "like Maybe" $
\x -> thOptionFieldToJSON (OptionField (Option x)) === thMaybeFieldToJSON (MaybeField x)
, testProperty "roundTrip" (toParseJSON thOptionFieldParseJSON thOptionFieldToJSON)
]
#endif
]
, testGroup "toEncoding" [
testProperty "NullaryString" $
Expand Down Expand Up @@ -124,7 +129,9 @@ templateHaskellTests =
, testProperty "OneConstructorTagged" $
thOneConstructorToJSONTagged `sameAs` thOneConstructorToEncodingTagged

#if !MIN_VERSION_base(4,16,0)
, testProperty "OptionField" $
thOptionFieldToJSON `sameAs` thOptionFieldToEncoding
#endif
]
]
2 changes: 2 additions & 0 deletions tests/SerializationFormatSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,10 @@ jsonExamples =
, example "Semigroup.First Int" "2" (pure 2 :: Semigroup.First Int)
, example "Semigroup.Last Int" "2" (pure 2 :: Semigroup.Last Int)
, example "Semigroup.WrappedMonoid Int" "2" (Semigroup.WrapMonoid 2 :: Semigroup.WrappedMonoid Int)
#if !MIN_VERSION_base(4,16,0)
, example "Semigroup.Option Just" "2" (pure 2 :: Semigroup.Option Int)
, example "Semigroup.Option Nothing" "null" (Semigroup.Option (Nothing :: Maybe Bool))
#endif

-- time 1.9
, example "SystemTime" "123.123456789" (MkSystemTime 123 123456789)
Expand Down
6 changes: 6 additions & 0 deletions tests/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import Data.Data
import Data.Functor.Compose (Compose (..))
import Data.Functor.Identity (Identity (..))
import Data.Hashable (Hashable (..))
#if !MIN_VERSION_base(4,16,0)
import Data.Semigroup (Option)
#endif
import Data.Text
import Data.Time (Day (..), fromGregorian)
import GHC.Generics
Expand Down Expand Up @@ -107,8 +109,10 @@ deriving instance Eq (GADT a)
deriving instance Show (GADT a)

newtype MaybeField = MaybeField { maybeField :: Maybe Int }
#if !MIN_VERSION_base(4,16,0)
newtype OptionField = OptionField { optionField :: Option Int }
deriving (Eq, Show)
#endif

deriving instance Generic Foo
deriving instance Generic UFoo
Expand All @@ -120,7 +124,9 @@ deriving instance Generic (Approx a)
deriving instance Generic Nullary
deriving instance Generic (SomeType a)
deriving instance Generic1 SomeType
#if !MIN_VERSION_base(4,16,0)
deriving instance Generic OptionField
#endif
deriving instance Generic EitherTextInt

failure :: Show a => String -> String -> a -> Property
Expand Down