waargonaut 0.5.2.1 → 0.5.2.2
raw patch · 7 files changed
+51/−20 lines, 7 filesdep ~basedep ~generics-sopdep ~tasty
Dependency ranges changed: base, generics-sop, tasty
Files
- src/Waargonaut/Types/CommaSep.hs +3/−2
- src/Waargonaut/Types/JArray.hs +3/−2
- src/Waargonaut/Types/JObject.hs +4/−3
- src/Waargonaut/Types/Whitespace.hs +3/−2
- test/Json.hs +24/−0
- test/Main.hs +2/−0
- waargonaut.cabal +12/−11
src/Waargonaut/Types/CommaSep.hs view
@@ -48,11 +48,12 @@ import Control.Lens (AsEmpty (..), Cons (..), Index, Iso, Iso', IxValue, Ixed (..), Lens',- Snoc (..), cons, from, isn't, iso,+ Snoc (..), cons, from, iso, mapped, nearly, over, prism, snoc, to, traverse, unsnoc, (%%~), (%~), (.~), (^.), (^..), (^?), _1, _2, _Cons, _Just, _Nothing)+import Control.Lens.Extras (is) import Control.Error.Util (note) import Control.Monad (Monad)@@ -308,7 +309,7 @@ {-# INLINE unconsCommaSep #-} instance (Semigroup ws, Monoid ws) => AsEmpty (CommaSeparated ws a) where- _Empty = nearly mempty (^. _CommaSeparated . _2 . to (isn't _Nothing))+ _Empty = nearly mempty (^. _CommaSeparated . _2 . to (is _Nothing)) type instance IxValue (CommaSeparated ws a) = a type instance Index (CommaSeparated ws a) = Int
src/Waargonaut/Types/JArray.hs view
@@ -22,9 +22,10 @@ import Control.Category ((.)) import Control.Error.Util (note) import Control.Lens (AsEmpty (..), Cons (..), Rewrapped, Ixed (..), Index, IxValue,- Wrapped (..), cons, isn't, iso,+ Wrapped (..), cons, iso, nearly, over, prism, to, ( # ), (^.), (^?), _2, _Wrapped)+import Control.Lens.Extras (is) import Control.Monad (Monad) import Data.Bifoldable (Bifoldable (bifoldMap))@@ -74,7 +75,7 @@ {-# INLINE _Cons #-} instance (Semigroup ws, Monoid ws) => AsEmpty (JArray ws a) where- _Empty = nearly (JArray mempty) (^. _Wrapped . to (isn't _Empty))+ _Empty = nearly (JArray mempty) (^. _Wrapped . to (is _Empty)) {-# INLINE _Empty #-} instance (Monoid ws, Semigroup ws) => Semigroup (JArray ws a) where
src/Waargonaut/Types/JObject.hs view
@@ -38,8 +38,9 @@ import Control.Lens (AsEmpty (..), At (..), Index, IxValue, Ixed (..), Lens', Prism', Rewrapped, Wrapped (..), cons,- isn't, iso, nearly, prism', to,+ iso, nearly, prism', to, ( # ), (.~), (<&>), (^.), _Wrapped)+import Control.Lens.Extras (is) import Control.Monad (Monad) import Data.Bifoldable (Bifoldable (bifoldMap))@@ -153,7 +154,7 @@ deriving (Eq, Show, Functor, Foldable, Traversable) instance (Semigroup ws, Monoid ws) => AsEmpty (JObject ws a) where- _Empty = nearly (_Wrapped # _Empty # ()) (^. _Wrapped . to (isn't _Empty))+ _Empty = nearly (_Wrapped # _Empty # ()) (^. _Wrapped . to (is _Empty)) {-# INLINE _Empty #-} instance JObject ws a ~ t => Rewrapped (JObject ws a) t@@ -219,7 +220,7 @@ _Wrapped' = iso (\ (MLO x) -> x) MLO instance (Monoid ws, Semigroup ws) => AsEmpty (MapLikeObj ws a) where- _Empty = nearly (_Wrapped # _Empty # ()) (^. _Wrapped . to (isn't _Empty))+ _Empty = nearly (_Wrapped # _Empty # ()) (^. _Wrapped . to (is _Empty)) {-# INLINE _Empty #-} type instance IxValue (MapLikeObj ws a) = a
src/Waargonaut/Types/Whitespace.hs view
@@ -21,9 +21,10 @@ import Control.Applicative (liftA2) import Control.Lens (AsEmpty (..), Cons (..), Prism',- Rewrapped, Wrapped (..), isn't, iso,+ Rewrapped, Wrapped (..), iso, mapped, nearly, over, prism, prism', to, uncons, (^.), _2, _Wrapped)+import Control.Lens.Extras (is) import Data.Text.Lazy.Builder (Builder) import qualified Data.Text.Lazy.Builder as TB@@ -68,7 +69,7 @@ {-# INLINE _Cons #-} instance AsEmpty WS where- _Empty = nearly mempty (^. _Wrapped . to (isn't _Empty))+ _Empty = nearly mempty (^. _Wrapped . to (is _Empty)) {-# INLINE _Empty #-} instance WS ~ t => Rewrapped WS t
+ test/Json.hs view
@@ -0,0 +1,24 @@+module Json+ ( jsonTests+ ) where++import Control.Lens (review,preview,_Empty)+import Test.Tasty+import Test.Tasty.HUnit+import Waargonaut.Types+++jsonTests :: TestTree+jsonTests =+ testGroup "Json types"+ [ testCase "CommandSepareted's _Empty prism law"+ $ preview _Empty (review _Empty () :: CommaSeparated WS (JAssoc WS Json)) @?= Just ()+ , testCase "JObject's _Empty prism law"+ $ preview _Empty (review _Empty () :: JObject WS Json) @?= Just ()+ , testCase "JArray's _Empty prism law"+ $ preview _Empty (review _Empty () :: JArray WS Json) @?= Just ()+ , testCase "MapLikeObj's _Empty prism law"+ $ preview _Empty (review _Empty () :: MapLikeObj WS Json) @?= Just ()+ , testCase "WS's _Empty prism law"+ $ preview _Empty (review _Empty () :: WS) @?= Just ()+ ]
test/Main.hs view
@@ -66,6 +66,7 @@ import qualified Decoder.Laws import qualified Encoder import qualified Encoder.Laws+import qualified Json encodeText :: Json@@ -313,6 +314,7 @@ , tripping_properties , unitTests , regressionTests+ , Json.jsonTests , mishandlingOfCharVsUtf8Bytes , Decoder.decoderTests
waargonaut.cabal view
@@ -10,7 +10,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.5.2.1+version: 0.5.2.2 -- A short (one-line) description of the package. synopsis: JSON wrangling@@ -57,14 +57,13 @@ -- Constraint on the version of Cabal needed to build this package. cabal-version: >=1.10 -tested-with: GHC==7.10.3- , GHC==8.0.2+tested-with: GHC==8.0.2 , GHC==8.2.2 , GHC==8.4.4 , GHC==8.6.2 custom-setup- setup-depends: base >= 4 && <5+ setup-depends: base >= 4.9 && <5 , cabal-doctest >= 1 && <1.1 , Cabal @@ -104,7 +103,7 @@ ghc-options: -Wall -- Other library packages from which modules are imported.- build-depends: base >= 4.7 && < 4.13+ build-depends: base >= 4.9 && < 4.13 , lens >= 4.15 && < 4.18 , mtl >= 2.2.2 && < 2.3 , text >= 1.2 && < 1.3@@ -121,7 +120,7 @@ , hoist-error >= 0.2 && < 0.3 , containers >= 0.5.6 && < 0.7 , witherable >= 0.2 && < 0.4- , generics-sop >= 0.3.2 && < 0.4+ , generics-sop >= 0.4 && < 0.5 , mmorph >= 1.1 && < 1.2 , transformers >= 0.4 && < 0.6 , bifunctors >= 5 && < 5.6@@ -148,7 +147,7 @@ default-language: Haskell2010 hs-source-dirs: test - build-depends: base >= 4.7 && < 4.13+ build-depends: base >= 4.9 && < 4.13 , hedgehog >= 0.6 && < 0.7 , text >= 1.2 && < 1.3 , digit >= 0.7 && < 0.8@@ -165,7 +164,8 @@ test-suite waarg-tests other-modules: Types.Common , Types.CommaSep- , Types.JChar , Types.JNumber+ , Types.JChar+ , Types.JNumber , Types.JString , Types.Json , Types.Whitespace@@ -176,13 +176,14 @@ , Encoder.Laws , Decoder , Decoder.Laws+ , Json type: exitcode-stdio-1.0 main-is: Main.hs hs-source-dirs: test - build-depends: base >= 4.7 && < 4.13- , tasty >= 0.11 && < 1.2+ build-depends: base >= 4.9 && < 4.13+ , tasty >= 0.11 && < 1.3 , tasty-hunit >= 0.10 && < 0.11 , tasty-expected-failure >= 0.11 && < 0.12 , hedgehog >= 0.6 && < 0.7@@ -196,7 +197,7 @@ , semigroups >= 0.8.4 && < 0.19 , zippers >= 0.2 && < 0.3 , vector >= 0.12 && < 0.13- , generics-sop >= 0.3.2 && < 0.4+ , generics-sop >= 0.4 && < 0.5 , attoparsec >= 0.13 && < 0.15 , scientific >= 0.3 && < 0.4 , tagged >= 0.8.5 && < 0.9