packages feed

safe-json 1.1.1 → 1.1.1.1

raw patch · 4 files changed

+31/−23 lines, 4 filesdep ~generic-arbitrarydep ~tastyPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: generic-arbitrary, tasty

API changes (from Hackage documentation)

- Data.SafeJSON.Test: data Proxy (t :: k) :: forall k. () => k -> Type
+ Data.SafeJSON.Test: data Proxy (t :: k)
- Data.SafeJSON.Test: Proxy :: Proxy
+ Data.SafeJSON.Test: Proxy :: Proxy (t :: k)

Files

ChangeLog.md view
@@ -1,5 +1,10 @@ # Changelog for safe-json +## 1.1.1.1++* loosened dependecy restriction on `tasty`+* fixed some documentation+ ## 1.1.1  * Fix clash in `test/Instances.hs` of `Ord` instance for `Data.Aeson.Value` [#23]
safe-json.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 9f89193c837c28565cd4e290695062fc359c44477f129d058d3f4e5971ec0e1b+-- hash: b7372a5a81832b55c168d9e63f92b1a4899ff44b801f2be33d799d7ca2902655  name:           safe-json-version:        1.1.1+version:        1.1.1.1 synopsis:       Automatic JSON format versioning description:    This library aims to make the updating of JSON formats or contents, while keeping backward compatibility, as painless as possible. The way this is achieved is through versioning and defined migration functions to migrate older (or newer) versions to the one used.                 .@@ -28,7 +28,7 @@ copyright:      2019 Felix Paulusma license:        MIT license-file:   LICENSE-tested-with:    GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.4, GHC == 8.6.5, GHC == 8.8.3+tested-with:    GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.4, GHC == 8.6.5, GHC == 8.8.4 build-type:     Simple extra-source-files:     README@@ -69,7 +69,7 @@     , dlist >=0.8.0.3 && <2     , hashable >=1.2.6.1 && <1.4     , scientific >=0.3.5.2 && <0.4-    , tasty >=0.11.3 && <1.4+    , tasty >=0.11.3 && <1.5     , tasty-hunit >=0.9.2 && <0.11     , tasty-quickcheck >=0.8.4 && <0.11     , text >=1.2.3 && <1.3
src/Data/Aeson/Safe.hs view
@@ -79,7 +79,7 @@   , encode   , encodeFile   )-import Data.Aeson.Types+import Data.Aeson.Types (Parser, parseEither, parseMaybe) import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as LBS import Data.SafeJSON
src/Data/SafeJSON/Internal.hs view
@@ -9,17 +9,14 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE CPP #-} {-# LANGUAGE DefaultSignatures #-}-{-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE UndecidableInstances #-} {-| Module      : Data.SafeJSON.Internal@@ -50,7 +47,7 @@ import Data.HashMap.Strict as HM (insert, size) import qualified Data.HashMap.Strict as HM (HashMap, delete, fromList, lookup, toList) import qualified Data.HashSet as HS (HashSet, fromList, toList)-import Data.Int+import Data.Int (Int16, Int32, Int64, Int8) import Data.IntMap as IM (IntMap, fromList) import Data.IntSet (IntSet) import qualified Data.List as List (intercalate, lookup)@@ -62,7 +59,7 @@ #else import Data.Monoid (Dual(..), (<>)) #endif-import Data.Proxy+import Data.Proxy (Proxy (..)) import Data.Ratio (Ratio) import Data.Scientific (Scientific) import Data.Semigroup (First(..), Last(..), Max(..), Min(..))@@ -71,6 +68,13 @@ import Data.Text as T (Text) import qualified Data.Text.Lazy as LT (Text) import Data.Time+    ( Day,+      DiffTime,+      NominalDiffTime,+      UTCTime,+      LocalTime,+      TimeOfDay,+      ZonedTime ) import Data.Tree (Tree) import Data.Typeable (Typeable, typeRep) import Data.UUID.Types (UUID)@@ -196,7 +200,7 @@ --   'safeToJSON'. newtype Contained a = Contained {unsafeUnpack :: a}   -- Opens up mis-use of 'safeFrom' / 'safeTo', better to not-  -- deriving (Functor)+  -- derive a Functor instance  -- | Used when defining 'safeFrom' or 'safeTo'. contain :: a -> Contained a@@ -228,7 +232,7 @@  -- | Same as 'setVersion', but requires a 'Version' parameter. ----- >>> 'encode' $ 'setVersion'' ('version' :: 'Version' Test) val+-- >>> encode $ setVersion' (version :: Version Test) val -- "{\"~v\":0,\"~d\":\"test\"}" -- -- @since 1.0.0@@ -314,7 +318,7 @@  -- 'Version Nothing' is handled as if it's mempty... mostly. -- | It is strongly discouraged to use any methods other---   than 'fromInteger' of 'Version'\'s 'Num' instance.+--   than 'fromInteger' of 'Version''s 'Num' instance. instance Num (Version a) where   Version ma + Version mb = Version $ liftV 0 (+) ma mb   Version ma - Version mb = Version $ liftV 0 (-) ma mb@@ -412,8 +416,8 @@ --   __your instances in a production setting.__ safeToJSON :: forall a. SafeJSON a => a -> Value safeToJSON a = case thisKind of-    Base          | i == Nothing -> tojson-    Extended Base | i == Nothing -> tojson+    Base          | isNothing i -> tojson+    Extended Base | isNothing i -> tojson     _ -> setVersion @a tojson   where tojson = unsafeUnpack $ safeTo a         Version i = version :: Version a@@ -441,8 +445,8 @@ safeFromJSON origVal = checkConsistency p $ \vs -> do     let hasVNil = noVersionPresent vs     case origKind of-      Base       | i == Nothing -> unsafeUnpack $ safeFrom origVal-      Extended k | i == Nothing -> extendedCase hasVNil k+      Base       | isNothing i -> unsafeUnpack $ safeFrom origVal+      Extended k | isNothing i -> extendedCase hasVNil k       _ -> regularCase hasVNil   where Version i = version :: Version a         origKind = kind :: Kind a@@ -682,7 +686,7 @@           ]       | otherwise = case k of           Base -> Nothing-          Extends{} | i == Nothing -> Just $ mconcat+          Extends{} | isNothing i -> Just $ mconcat               [ typeName p, " has defined 'version = noVersion', "               , " but it's 'kind' definition is not 'base' or 'extended_base'"               ]@@ -937,10 +941,10 @@   typeName = typeName1   version = noVersion --- | Lists and any other "container" are seen as only that:+-- | Lists and any other \"container\" are seen as only that: --   a container for 'SafeJSON' values. -----   "Containers" are implemented in such a way that when parsing+--   \"Containers\" are implemented in such a way that when parsing --   a collection of all migratable versions, the result will be --   a list of that type where each element has been migrated as --   appropriate.@@ -954,9 +958,8 @@  #define BASIC_UNARY_FUNCTOR(T)                      \ instance SafeJSON a => SafeJSON (T a) where {       \-  safeFrom val = contain $ do {                     \-      vs <- parseJSON val;                          \-      mapM safeFromJSON vs };                       \+  safeFrom val = contain $                          \+      parseJSON val >>= mapM safeFromJSON;          \   safeTo as = contain . toJSON $ safeToJSON <$> as; \   typeName = typeName1;                             \   version = noVersion }