aeson-yaml 1.1.0.0 → 1.1.0.1
raw patch · 4 files changed
+46/−11 lines, 4 filesdep −tasty-discoverdep ~aesondep ~bytestringdep ~textPVP ok
version bump matches the API change (PVP)
Dependencies removed: tasty-discover
Dependency ranges changed: aeson, bytestring, text, vector
API changes (from Hackage documentation)
Files
- CHANGELOG.md +6/−0
- aeson-yaml.cabal +4/−4
- src/Data/Aeson/Yaml.hs +21/−5
- test/Test/Data/Aeson/Yaml.hs +15/−2
CHANGELOG.md view
@@ -1,5 +1,11 @@ # Changelog +## 1.1.0.1 - 2021-11-13++### Changed++ - Support aeson-2.0 (thanks to Simon Jakobi)+ ## 1.1.0.0 - 2020-06-25 ### Changed
aeson-yaml.cabal view
@@ -1,7 +1,7 @@ cabal-version: 1.12 name: aeson-yaml-version: 1.1.0.0+version: 1.1.0.1 homepage: https://github.com/clovyr/aeson-yaml bug-reports: https://github.com/clovyr/aeson-yaml/issues author: Patrick Nielsen@@ -37,9 +37,9 @@ exposed-modules: Data.Aeson.Yaml build-depends:- aeson >= 0.4.0.0 && < 1.6+ aeson >= 0.4.0.0 && < 2.1 , base >= 4.8.2.0 && < 5- , bytestring >= 0.10.4.0 && < 0.11+ , bytestring >= 0.10.4.0 && < 0.12 , text >= 0.1 && < 1.3 , unordered-containers >= 0.1.0.0 && < 0.3 , vector >= 0.1 && < 0.13@@ -61,10 +61,10 @@ -- , hedgehog-gen-json , string-qq , tasty- , tasty-discover , tasty-hunit , unordered-containers , yaml+ build-tool-depends: tasty-discover:tasty-discover type: exitcode-stdio-1.0 default-language: Haskell2010
src/Data/Aeson/Yaml.hs view
@@ -8,6 +8,7 @@ This module is meant to be imported qualified. -}+{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} module Data.Aeson.Yaml@@ -25,14 +26,22 @@ import qualified Data.ByteString.Lazy as ByteString.Lazy import qualified Data.ByteString.Short as ByteString.Short import Data.Char (isAlpha, isDigit)-import qualified Data.HashMap.Strict as HashMap-import Data.List (intersperse, sortOn)+import Data.List (intersperse) import Data.Monoid ((<>), mconcat, mempty) import qualified Data.Text as Text import Data.Text (Text) import qualified Data.Text.Encoding as Text.Encoding import qualified Data.Vector as Vector +#if MIN_VERSION_aeson(2,0,0)+import qualified Data.Aeson.Key as Key+import qualified Data.Aeson.KeyMap as KeyMap+import Data.Bifunctor (first)+#else+import qualified Data.HashMap.Strict as HashMap+import Data.List (sortOn)+#endif+ b :: ByteString -> Builder b = ByteString.Builder.byteString @@ -81,15 +90,15 @@ encodeBuilder :: Bool -> Bool -> Int -> Data.Aeson.Value -> Builder encodeBuilder alwaysQuote newlineBeforeObject level value = case value of- Object hm- | null hm -> bs "{}"+ Object km+ | null km -> bs "{}" | otherwise -> mconcat $ (if newlineBeforeObject then (prefix :) else id) $ intersperse prefix $- map (keyValue level) (sortOn fst $ HashMap.toList hm)+ map (keyValue level) (objectToAscList km) where prefix = bs "\n" <> indent level Array vec | null vec -> bs "[]"@@ -173,3 +182,10 @@ case ls of (line:_) -> " " `Text.isPrefixOf` line _ -> False++objectToAscList :: Object -> [(Text, Value)]+#if MIN_VERSION_aeson(2,0,0)+objectToAscList = map (first Key.toText) . KeyMap.toAscList+#else+objectToAscList = sortOn fst . HashMap.toList+#endif
test/Test/Data/Aeson/Yaml.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE QuasiQuotes #-}@@ -7,10 +8,15 @@ import qualified Data.Aeson import qualified Data.ByteString.Lazy import Data.Either (fromRight)-import qualified Data.HashMap.Strict as HashMap import Data.String.QQ (s) import qualified Data.Yaml +#if MIN_VERSION_aeson(2,0,0)+import qualified Data.Aeson.KeyMap as KeyMap+#else+import qualified Data.HashMap.Strict as HashMap+#endif+ -- import Hedgehog -- import Hedgehog.Gen -- import Hedgehog.Gen.JSON (genJSONValue, sensibleRanges)@@ -243,7 +249,14 @@ } foo :: Data.Aeson.Value-foo = Data.Aeson.Object $ HashMap.fromList [("foo", "bar")]+foo =+ Data.Aeson.Object $+#if MIN_VERSION_aeson(2,0,0)+ KeyMap.fromList+#else+ HashMap.fromList+#endif+ [("foo", "bar")] test_testCases :: TestTree test_testCases = testGroup "Test Cases" $ map mkTestCase testCases