packages feed

keys 3.10.1 → 3.10.2

raw patch · 4 files changed

+122/−5 lines, 4 filesdep +hashabledep +unordered-containersdep ~semigroupoidsPVP ok

version bump matches the API change (PVP)

Dependencies added: hashable, unordered-containers

Dependency ranges changed: semigroupoids

API changes (from Hackage documentation)

+ Data.Key: instance (Eq k, Hashable k) => Indexable (HashMap k)
+ Data.Key: instance (Eq k, Hashable k) => Lookup (HashMap k)
+ Data.Key: instance (Eq k, Hashable k) => Zip (HashMap k)
+ Data.Key: instance (Eq k, Hashable k) => ZipWithKey (HashMap k)
+ Data.Key: instance FoldableWithKey ((,) k)
+ Data.Key: instance FoldableWithKey (HashMap k)
+ Data.Key: instance FoldableWithKey Maybe
+ Data.Key: instance FoldableWithKey1 ((,) k)
+ Data.Key: instance Indexable Maybe
+ Data.Key: instance Keyed ((,) k)
+ Data.Key: instance Keyed (HashMap k)
+ Data.Key: instance Keyed Maybe
+ Data.Key: instance Lookup Maybe
+ Data.Key: instance TraversableWithKey ((,) k)
+ Data.Key: instance TraversableWithKey (HashMap k)
+ Data.Key: instance TraversableWithKey Maybe
+ Data.Key: instance TraversableWithKey1 ((,) k)
+ Data.Key: instance Zip Maybe
+ Data.Key: instance ZipWithKey Maybe

Files

+ CHANGELOG.markdown view
@@ -0,0 +1,27 @@+3.10.2+------+* Support for `semigroupoids` 5.++3.10.1+------+* Support for `transformers` 0.4.++3.10+----+* Updated to use `free`, `semigroupoids`, `comonad` version 4.0++3.0.4+-----+* Updated array dependency+* Added proper upper bounds to other dependencies++3.0.3+-----+* This package is now `Trustworthy`++3.0.2+-----+* Removed upper bounds on my other dependencies+* Directory layout change+* Added support files+* Travis build notification to IRC
+ README.markdown view
@@ -0,0 +1,18 @@+keys+====++[![Build Status](https://secure.travis-ci.org/ekmett/keys.png?branch=master)](http://travis-ci.org/ekmett/keys)++This package provides a bunch of ad hoc classes for accessing parts of a container.++In practice this package is largely subsumed by the `lens` package, but it is maintained for now+as it has much simpler dependencies.++Contact Information+-------------------++Contributions and bug reports are welcome!++Please feel free to contact me through github or on the #haskell IRC channel on irc.freenode.net.++-Edward Kmett
keys.cabal view
@@ -1,6 +1,6 @@ name:          keys category:      Data Structures, Containers-version:       3.10.1+version:       3.10.2 license:       BSD3 cabal-version: >= 1.6 license-file:  LICENSE@@ -13,7 +13,7 @@ synopsis:      Keyed functors and containers description:   Keyed functors and containers build-type:    Simple-extra-source-files: .travis.yml+extra-source-files: .travis.yml CHANGELOG.markdown README.markdown  source-repository head   type: git@@ -26,9 +26,11 @@     comonad              >= 4       && < 5,     containers           >= 0.3     && < 0.6,     free                 >= 4       && < 5,-    semigroupoids        >= 4       && < 5,+    hashable             >= 1.1.2.3 && < 1.3,+    semigroupoids        >= 4       && < 6,     semigroups           >= 0.8.3.1 && < 1,-    transformers         >= 0.2     && < 0.5+    transformers         >= 0.2     && < 0.5,+    unordered-containers >= 0.2     && < 0.3    exposed-modules:     Data.Key
src/Data/Key.hs view
@@ -78,6 +78,9 @@ import Data.Functor.Product import Data.Functor.Coproduct import Data.Foldable+import Data.Hashable+import Data.HashMap.Lazy (HashMap)+import qualified Data.HashMap.Lazy as HashMap import Data.IntMap (IntMap) import qualified Data.IntMap as IntMap import Data.Ix hiding (index)@@ -86,7 +89,7 @@ import Data.Tree import Data.List.NonEmpty (NonEmpty(..)) import qualified Data.List.NonEmpty as NonEmpty-import Data.Maybe (listToMaybe)+import Data.Maybe (fromJust, listToMaybe) import qualified Data.Monoid as Monoid import Data.Semigroup hiding (Product) import Data.Semigroup.Foldable@@ -830,3 +833,70 @@   replace (Left i) v (Pair a b) = Pair (replace i v a) b   replace (Right j) v (Pair a b) = Pair a (replace j v b) +type instance Key ((,) k) = k++instance Keyed ((,) k) where+  mapWithKey f (k, a) = (k, f k a)++instance FoldableWithKey ((,) k) where+  foldMapWithKey = uncurry++instance FoldableWithKey1 ((,) k) where+  foldMapWithKey1 = uncurry++instance TraversableWithKey ((,) k) where+  traverseWithKey f (k, a) = (,) k <$> f k a++instance TraversableWithKey1 ((,) k) where+  traverseWithKey1 f (k, a) = (,) k <$> f k a++type instance Key (HashMap k) = k++instance Keyed (HashMap k) where+  mapWithKey = HashMap.mapWithKey++instance (Eq k, Hashable k) => Indexable (HashMap k) where+  index = (HashMap.!)++instance (Eq k, Hashable k) => Lookup (HashMap k) where+  lookup = HashMap.lookup++instance (Eq k, Hashable k) => Zip (HashMap k) where+  zipWith = HashMap.intersectionWith++instance (Eq k, Hashable k) => ZipWithKey (HashMap k) where+  zipWithKey f a b = HashMap.foldlWithKey' go HashMap.empty a+    where+      go m k v = case lookup k b of+                   Just w -> HashMap.insert k (f k v w) m+                   _      -> m++instance FoldableWithKey (HashMap k) where+  foldrWithKey = HashMap.foldrWithKey++instance TraversableWithKey (HashMap k) where+  traverseWithKey = HashMap.traverseWithKey++type instance Key Maybe = ()++instance Keyed Maybe where+  mapWithKey f = fmap (f ())++instance Indexable Maybe where+  index = const . fromJust++instance Lookup Maybe where+  lookup _ mb = mb++instance Zip Maybe where+  zipWith f (Just a) (Just b) = Just (f a b)+  zipWith _ _        _        = error "zipWith: Nothing"++instance ZipWithKey Maybe where+  zipWithKey f = zipWith (f ())++instance FoldableWithKey Maybe where+  foldMapWithKey f = foldMap (f ())++instance TraversableWithKey Maybe where+  traverseWithKey f = traverse (f ())