aeson-combinators 0.0.1.1 → 0.0.2.0
raw patch · 2 files changed
+37/−10 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
aeson-combinators.cabal view
@@ -1,6 +1,6 @@ cabal-version: >=1.10 name: aeson-combinators-version: 0.0.1.1+version: 0.0.2.0 synopsis: Aeson combinators for dead simple JSON decoding description: This library defines low overhead value space `Decoder`@@ -22,6 +22,7 @@ , GHC == 7.6.3 , GHC == 8.4.4 , GHC == 8.6.5+ , GHCJS == 8.6.0.1 library exposed-modules: Data.Aeson.Combinators.Decode
lib/Data/Aeson/Combinators/Decode.hs view
@@ -46,7 +46,10 @@ -- * Decoding Time , zonedTime, localTime, timeOfDay , utcTime- , day, dayOfWeek+ , day+#if (MIN_VERSION_time_compat(1,9,2))+ , dayOfWeek+#endif -- * Decodeing Containers -- *** Maybe , nullable@@ -84,6 +87,7 @@ import Control.Monad hiding (void) import Control.Monad.Fail (MonadFail (..)) import qualified Control.Monad.Fail as Fail+import Data.Aeson.Internal (JSONPath, JSONPathElement (..)) import qualified Data.Aeson.Internal as AI import qualified Data.Aeson.Parser as Parser import qualified Data.Aeson.Parser.Internal as ParserI@@ -93,7 +97,9 @@ import Data.Int (Int16, Int32, Int64, Int8) import Data.Text (Text) import Data.Time.Calendar (Day)+#if (MIN_VERSION_time_compat(1,9,2)) import Data.Time.Calendar.Compat (DayOfWeek)+#endif import Data.Time.Clock (UTCTime) import Data.Time.LocalTime (LocalTime, TimeOfDay, ZonedTime) import Data.UUID.Types (UUID)@@ -447,11 +453,15 @@ day = auto {-# INLINE day #-} +#if (MIN_VERSION_time_compat(1,9,2)) -- | Decode JSON string to 'Data.Time.Calendar.Compat.DayOfWeek' -- using Aesons's instance implementation+--+-- This function requires 'time-compat' >= 1.9.2 dayOfWeek :: Decoder DayOfWeek dayOfWeek = auto {-# INLINE dayOfWeek #-}+#endif -- Continer Decoders@@ -736,13 +746,29 @@ -- Private functions Aeson doesn't expose --- | Annotate an error message with a--- <http://goessner.net/articles/JsonPath/ JSONPath> error location.-formatError :: JSONPath -> String -> String-formatError pth msg =- "Error in " ++ formatPath pth ++ ": " ++ msg-{-# INLINE formatError #-}- eitherFormatError :: Either (JSONPath, String) a -> Either String a-eitherFormatError = either (Left . uncurry formatError) Right+eitherFormatError = either (Left . uncurry AI.formatError) Right {-# INLINE eitherFormatError #-}++#if (MIN_VERSION_aeson(1,4,3))+#else++-- These functions are not exposed in aeson 1.4.2.0+-- implementation is copied from+-- https://hackage.haskell.org/package/aeson-1.4.6.0/docs/src/Data.Aeson.Types.FromJSON.html#unexpected++unexpected :: Value -> Parser a+unexpected actual = Fail.fail $ "unexpected " ++ typeOf actual+{-# INLINE unexpected #-}++typeOf :: Value -> String+typeOf v = case v of+ Object _ -> "Object"+ Array _ -> "Array"+ String _ -> "String"+ Number _ -> "Number"+ Bool _ -> "Boolean"+ Null -> "Null"+{-# INLINE typeOf #-}++#endif