insert-ordered-containers 0.2.3.1 → 0.2.4
raw patch · 3 files changed
+42/−18 lines, 3 filesdep +indexed-traversabledep ~basedep ~lensdep ~optics-corePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: indexed-traversable
Dependency ranges changed: base, lens, optics-core, optics-extra, tasty
API changes (from Hackage documentation)
- Data.HashMap.Strict.InsOrd: instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k) => Control.Lens.Indexed.FoldableWithIndex k (Data.HashMap.Strict.InsOrd.InsOrdHashMap k)
- Data.HashMap.Strict.InsOrd: instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k) => Control.Lens.Indexed.FunctorWithIndex k (Data.HashMap.Strict.InsOrd.InsOrdHashMap k)
- Data.HashMap.Strict.InsOrd: instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k) => Control.Lens.Indexed.TraversableWithIndex k (Data.HashMap.Strict.InsOrd.InsOrdHashMap k)
- Data.HashMap.Strict.InsOrd: instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k) => Optics.Internal.Indexed.Classes.FoldableWithIndex k (Data.HashMap.Strict.InsOrd.InsOrdHashMap k)
- Data.HashMap.Strict.InsOrd: instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k) => Optics.Internal.Indexed.Classes.FunctorWithIndex k (Data.HashMap.Strict.InsOrd.InsOrdHashMap k)
- Data.HashMap.Strict.InsOrd: instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k) => Optics.Internal.Indexed.Classes.TraversableWithIndex k (Data.HashMap.Strict.InsOrd.InsOrdHashMap k)
+ Data.HashMap.Strict.InsOrd: instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k) => WithIndex.FoldableWithIndex k (Data.HashMap.Strict.InsOrd.InsOrdHashMap k)
+ Data.HashMap.Strict.InsOrd: instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k) => WithIndex.FunctorWithIndex k (Data.HashMap.Strict.InsOrd.InsOrdHashMap k)
+ Data.HashMap.Strict.InsOrd: instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k) => WithIndex.TraversableWithIndex k (Data.HashMap.Strict.InsOrd.InsOrdHashMap k)
Files
- CHANGELOG.md +4/−0
- insert-ordered-containers.cabal +9/−8
- src/Data/HashMap/Strict/InsOrd.hs +29/−10
CHANGELOG.md view
@@ -1,3 +1,7 @@+- 0.2.4+ - Add `indexed-traversable` instances+ - lens-5 and optics-0.4 support+ - 0.2.3 - Add support for indexed `optics` - Only support GHC-8.0+
insert-ordered-containers.cabal view
@@ -1,5 +1,5 @@ name: insert-ordered-containers-version: 0.2.3.1+version: 0.2.4 synopsis: Associative containers retaining insertion order for traversals. @@ -18,7 +18,7 @@ build-type: Simple cabal-version: >=1.10 tested-with:- GHC ==8.0.2 || ==8.2.2 || ==8.4.4 || ==8.6.5 || ==8.8.3 || ==8.10.1+ GHC ==8.0.2 || ==8.2.2 || ==8.4.4 || ==8.6.5 || ==8.8.4 || ==8.10.4 || ==9.0.1 extra-source-files: CHANGELOG.md@@ -33,13 +33,14 @@ hs-source-dirs: src ghc-options: -Wall build-depends:- aeson >=1.4.2.0 && <1.5- , base >=4.9 && <4.15+ aeson >=1.4.2.0 && <1.6+ , base >=4.9 && <4.16 , base-compat >=0.10.5 && <0.12 , hashable >=1.2.6.1 && <1.4- , lens >=4.17 && <4.20- , optics-core >=0.2 && <0.4- , optics-extra >=0.2 && <0.4+ , indexed-traversable >=0.1.1 && <0.2+ , lens >=4.17 && <5.1+ , optics-core >=0.2 && <0.5+ , optics-extra >=0.2 && <0.5 , semigroupoids >=5.3.2 && <5.4 , semigroups >=0.18.5 && <0.20 , text >=1.2.3.0 && <1.3@@ -70,7 +71,7 @@ , QuickCheck >=2.13.2 && <2.15 , semigroupoids , semigroups- , tasty >=0.10.1.2 && <1.3+ , tasty >=0.10.1.2 && <1.5 , tasty-quickcheck >=0.8.3.2 && <0.11 , text , transformers
src/Data/HashMap/Strict/InsOrd.hs view
@@ -86,21 +86,22 @@ 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.Lens- (At (..), FoldableWithIndex (..), FunctorWithIndex (..), Index, Iso,- IxValue, Ixed (..), TraversableWithIndex (..), Traversal, iso, (<&>),- _1, _2)+ (At (..), Index, Iso, IxValue, Ixed (..), Traversal, _1, _2, iso, (<&>)) import Control.Monad.Trans.State.Strict (State, runState, state) import qualified Control.Lens as Lens@@ -233,6 +234,18 @@ parseJSON = parseJSON1 -------------------------------------------------------------------------------+-- indexed-traversals+-------------------------------------------------------------------------------++instance (Eq k, Hashable k) => FunctorWithIndex k (InsOrdHashMap k) where+ imap = mapWithKey+instance (Eq k, Hashable k) => FoldableWithIndex k (InsOrdHashMap k) where+ ifoldMap = foldMapWithKey+ ifoldr = foldrWithKey+instance (Eq k, Hashable k) => TraversableWithIndex k (InsOrdHashMap k) where+ itraverse = traverseWithKey++------------------------------------------------------------------------------- -- Lens ------------------------------------------------------------------------------- @@ -262,13 +275,6 @@ where mv = lookup k m {-# INLINABLE at #-} -instance (Eq k, Hashable k) => FunctorWithIndex k (InsOrdHashMap k) where- imap = mapWithKey-instance (Eq k, Hashable k) => FoldableWithIndex k (InsOrdHashMap k) where- ifoldMap = foldMapWithKey-instance (Eq k, Hashable k) => TraversableWithIndex k (InsOrdHashMap k) where- itraverse = traverseWithKey- -- | This is a slight lie, as roundtrip doesn't preserve ordering. hashMap :: Iso (InsOrdHashMap k a) (InsOrdHashMap k b) (HashMap k a) (HashMap k b) hashMap = iso toHashMap fromHashMap@@ -276,6 +282,16 @@ unorderedTraversal :: Traversal (InsOrdHashMap k a) (InsOrdHashMap k b) a b unorderedTraversal = hashMap . traverse +#if !MIN_VERSION_lens(5,0,0)+instance (Eq k, Hashable k) => Lens.FunctorWithIndex k (InsOrdHashMap k) where+ imap = mapWithKey+instance (Eq k, Hashable k) => Lens.FoldableWithIndex k (InsOrdHashMap k) where+ ifoldMap = foldMapWithKey+ ifoldr = foldrWithKey+instance (Eq k, Hashable k) => Lens.TraversableWithIndex k (InsOrdHashMap k) where+ itraverse = traverseWithKey+#endif+ ------------------------------------------------------------------------------- -- Optics -------------------------------------------------------------------------------@@ -291,12 +307,15 @@ at k = Optics.lensVL $ \f m -> Lens.at k f m {-# INLINE at #-} +#if !MIN_VERSION_optics_core(0,4,0) instance (Eq k, Hashable k) => Optics.FunctorWithIndex k (InsOrdHashMap k) where imap = mapWithKey instance (Eq k, Hashable k) => Optics.FoldableWithIndex k (InsOrdHashMap k) where ifoldMap = foldMapWithKey+ ifoldr = foldrWithKey instance (Eq k, Hashable k) => Optics.TraversableWithIndex k (InsOrdHashMap k) where itraverse = traverseWithKey+#endif ------------------------------------------------------------------------------- -- Construction