insert-ordered-containers 0.2.5.2 → 0.2.5.3
raw patch · 4 files changed
+83/−49 lines, 4 filesdep ~aesondep ~basedep ~deepseqPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: aeson, base, deepseq, tasty, text
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- insert-ordered-containers.cabal +4/−4
- src/Data/HashMap/Strict/InsOrd.hs +61/−38
- src/Data/HashSet/InsOrd.hs +14/−7
CHANGELOG.md view
@@ -1,3 +1,7 @@+- 0.2.5.3+ - Support `aeson-2.2`+ - Make `Prelude` import explicit (safe guard against additions to `Prelude`).+ - 0.2.5.2 - Actually drop `semigroups` dependency - Update bounds
insert-ordered-containers.cabal view
@@ -1,5 +1,5 @@ name: insert-ordered-containers-version: 0.2.5.2+version: 0.2.5.3 synopsis: Associative containers retaining insertion order for traversals. @@ -25,9 +25,9 @@ || ==8.8.4 || ==8.10.7 || ==9.0.2- || ==9.2.7+ || ==9.2.8 || ==9.4.5- || ==9.6.1+ || ==9.6.2 extra-source-files: CHANGELOG.md@@ -42,7 +42,7 @@ hs-source-dirs: src ghc-options: -Wall build-depends:- aeson >=1.4.2.0 && <1.6 || >=2.0.0.0 && <2.2+ aeson >=1.4.2.0 && <1.6 || >=2.0.0.0 && <2.3 , base >=4.9 && <4.19 , deepseq >=1.4.2.0 && <1.5 , hashable >=1.2.6.1 && <1.5
src/Data/HashMap/Strict/InsOrd.hs view
@@ -77,36 +77,43 @@ valid, ) where -import Prelude hiding (filter, foldr, lookup, map, null)+import Prelude+ (Bool (..), Eq, Functor, Int, Maybe (..), all, const, flip, fmap, fst,+ id, maybe, otherwise, pure, return, snd, uncurry, ($), (&&), (+), (.),+ (<$>), (<), (==), (>), (>=), (>>=), (||)) -import Control.Applicative (Const (..))-import Control.Arrow (first, second)-import Control.DeepSeq (NFData (..))-import Data.Aeson-import qualified Data.Aeson.Encoding as E-import Data.Data (Data, Typeable)-import qualified Data.Foldable as F-import Data.Foldable.WithIndex (FoldableWithIndex (..))-import Data.Functor.Apply (Apply (..))-import Data.Functor.Bind (Bind (..))-import Data.Functor.WithIndex (FunctorWithIndex (..))-import Data.Hashable (Hashable (..))-import Data.List (nub, sortBy)-import Data.Maybe (fromMaybe)-import Data.Ord (comparing)-import Data.Semigroup (Semigroup (..))-import Data.Traversable.WithIndex (TraversableWithIndex (..))-import Text.ParserCombinators.ReadPrec (prec)-import Text.Read- (Lexeme (..), Read (..), lexP, parens, readListPrecDefault)+import Control.Applicative (Applicative, Const (..))+import Control.Arrow (first, second)+import Control.DeepSeq (NFData (..))+import Data.Data (Data, Typeable)+import Data.Foldable (Foldable (foldMap))+import Data.Foldable.WithIndex (FoldableWithIndex (..))+import Data.Functor.Apply (Apply (..))+import Data.Functor.Bind (Bind (..))+import Data.Functor.WithIndex (FunctorWithIndex (..))+import Data.Hashable (Hashable (..))+import Data.List (nub, sortBy)+import Data.Maybe (fromMaybe)+import Data.Monoid (Monoid, mappend, mempty)+import Data.Ord (comparing)+import Data.Semigroup (Semigroup (..))+import Data.Traversable (Traversable (traverse))+import Data.Traversable.WithIndex (TraversableWithIndex (..))+import Text.ParserCombinators.ReadPrec (prec)+import Text.Read+ (Lexeme (..), Read (..), lexP, parens, readListPrecDefault)+import Text.Show (Show (..), showParen, showString) import Control.Lens (At (..), Index, Iso, IxValue, Ixed (..), Traversal, _1, _2, iso, (<&>)) import Control.Monad.Trans.State.Strict (State, runState, state) -import qualified Control.Lens as Lens-import qualified Optics.At as Optics-import qualified Optics.Core as Optics+import qualified Control.Lens as Lens+import qualified Data.Aeson as A+import qualified Data.Aeson.Encoding as E+import qualified Data.Foldable as F+import qualified Optics.At as Optics+import qualified Optics.Core as Optics import Data.HashMap.Strict (HashMap) import qualified Data.HashMap.Strict as HashMap@@ -239,26 +246,42 @@ -- Aeson ------------------------------------------------------------------------------- -instance (ToJSONKey k) => ToJSON1 (InsOrdHashMap k) where- liftToJSON t _ = case toJSONKey :: ToJSONKeyFunction k of- ToJSONKeyText f _ -> object . fmap (\(k, v) -> (f k, t v)) . toList- ToJSONKeyValue f _ -> toJSON . fmap (\(k,v) -> toJSON (f k, t v)) . toList+instance (A.ToJSONKey k) => A.ToJSON1 (InsOrdHashMap k) where+#if MIN_VERSION_aeson(2,2,0)+ liftToJSON _ t _ = case A.toJSONKey :: A.ToJSONKeyFunction k of+ A.ToJSONKeyText f _ -> A.object . fmap (\(k, v) -> (f k, t v)) . toList+ A.ToJSONKeyValue f _ -> A.toJSON . fmap (\(k,v) -> A.toJSON (f k, t v)) . toList+#else+ liftToJSON t _ = case A.toJSONKey :: A.ToJSONKeyFunction k of+ A.ToJSONKeyText f _ -> A.object . fmap (\(k, v) -> (f k, t v)) . toList+ A.ToJSONKeyValue f _ -> A.toJSON . fmap (\(k,v) -> A.toJSON (f k, t v)) . toList+#endif - liftToEncoding t _ = case toJSONKey :: ToJSONKeyFunction k of- ToJSONKeyText _ f -> E.dict f t foldrWithKey- ToJSONKeyValue _ f -> E.list (liftToEncoding2 f (E.list f) t (E.list t)) . toList+#if MIN_VERSION_aeson(2,2,0)+ liftToEncoding o t _ = case A.toJSONKey :: A.ToJSONKeyFunction k of+ A.ToJSONKeyText _ f -> E.dict f t foldrWithKey+ A.ToJSONKeyValue _ f -> E.list (A.liftToEncoding2 (const False) f (E.list f) o t (E.list t)) . toList+#else+ liftToEncoding t _ = case A.toJSONKey :: A.ToJSONKeyFunction k of+ A.ToJSONKeyText _ f -> E.dict f t foldrWithKey+ A.ToJSONKeyValue _ f -> E.list (A.liftToEncoding2 f (E.list f) t (E.list t)) . toList+#endif -instance (ToJSONKey k, ToJSON v) => ToJSON (InsOrdHashMap k v) where- toJSON = toJSON1- toEncoding = toEncoding1+instance (A.ToJSONKey k, A.ToJSON v) => A.ToJSON (InsOrdHashMap k v) where+ toJSON = A.toJSON1+ toEncoding = A.toEncoding1 ------------------------------------------------------------------------------- -instance (Eq k, Hashable k, FromJSONKey k) => FromJSON1 (InsOrdHashMap k) where- liftParseJSON p pl v = fromList . HashMap.toList <$> liftParseJSON p pl v+instance (Eq k, Hashable k, A.FromJSONKey k) => A.FromJSON1 (InsOrdHashMap k) where+#if MIN_VERSION_aeson(2,2,0)+ liftParseJSON o p pl v = fromList . HashMap.toList <$> A.liftParseJSON o p pl v+#else+ liftParseJSON p pl v = fromList . HashMap.toList <$> A.liftParseJSON p pl v+#endif -instance (Eq k, Hashable k, FromJSONKey k, FromJSON v) => FromJSON (InsOrdHashMap k v) where- parseJSON = parseJSON1+instance (Eq k, Hashable k, A.FromJSONKey k, A.FromJSON v) => A.FromJSON (InsOrdHashMap k v) where+ parseJSON = A.parseJSON1 ------------------------------------------------------------------------------- -- indexed-traversals
src/Data/HashSet/InsOrd.hs view
@@ -43,24 +43,31 @@ valid, )where -import Prelude hiding (filter, foldr, lookup, map, null)+import Prelude+ (Bool, Eq ((==)), Int, Maybe (..), const, flip, fmap, fst,+ maybe, otherwise, return, snd, ($), (&&), (+), (.), (<$), (<$>), (<),+ (>), (>=), (||)) import Control.Arrow (first) import Control.DeepSeq (NFData (..))-import Data.Aeson import Data.Data (Data, Typeable)+import Data.Foldable (Foldable (foldMap), all) import Data.Hashable (Hashable (..)) import Data.List (nub, sortBy)+import Data.Monoid (Monoid (..)) import Data.Ord (comparing) import Data.Semigroup (Semigroup (..))+import Data.Traversable (Traversable (traverse)) import Text.ParserCombinators.ReadPrec (prec) import Text.Read (Lexeme (..), Read (..), lexP, parens, readListPrecDefault)+import Text.Show (Show (..), showParen, showString) import Control.Lens (At (..), Contains (..), Index, Iso', IxValue, Ixed (..), iso, (<&>)) import Control.Monad.Trans.State.Strict (State, runState, state) +import qualified Data.Aeson as A import qualified Control.Lens as Lens import qualified Optics.At as Optics import qualified Optics.Core as Optics@@ -146,12 +153,12 @@ -- Aeson ------------------------------------------------------------------------------- -instance ToJSON a => ToJSON (InsOrdHashSet a) where- toJSON = toJSON . toList- toEncoding = toEncoding . toList+instance A.ToJSON a => A.ToJSON (InsOrdHashSet a) where+ toJSON = A.toJSON . toList+ toEncoding = A.toEncoding . toList -instance (Eq a, Hashable a, FromJSON a) => FromJSON (InsOrdHashSet a) where- parseJSON v = fromList <$> parseJSON v+instance (Eq a, Hashable a, A.FromJSON a) => A.FromJSON (InsOrdHashSet a) where+ parseJSON v = fromList <$> A.parseJSON v ------------------------------------------------------------------------------- -- Lens