keys 3.12.2 → 3.12.3
raw patch · 4 files changed
+83/−37 lines, 4 filesdep ~base-orphansdep ~containersdep ~hashable
Dependency ranges changed: base-orphans, containers, hashable, semigroupoids, transformers
Files
- .travis.yml +32/−33
- CHANGELOG.markdown +6/−0
- keys.cabal +2/−2
- src/Data/Key.hs +43/−2
.travis.yml view
@@ -4,7 +4,7 @@ # # For more information, see https://github.com/haskell-CI/haskell-ci #-# version: 0.3.20190425+# version: 0.4 # language: c dist: xenial@@ -35,38 +35,36 @@ include: - compiler: ghc-8.8.1 addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.8.1","cabal-install-3.0"]}}- env: GHCHEAD=true - compiler: ghc-8.6.5- addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.6.5","cabal-install-2.4"]}}+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.6.5","cabal-install-3.0"]}} - compiler: ghc-8.4.4- addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.4.4","cabal-install-2.4"]}}+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.4.4","cabal-install-3.0"]}} - compiler: ghc-8.2.2- addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.2.2","cabal-install-2.4"]}}+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.2.2","cabal-install-3.0"]}} - compiler: ghc-8.0.2- addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.0.2","cabal-install-2.4"]}}+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.0.2","cabal-install-3.0"]}} - compiler: ghc-7.10.3- addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.10.3","cabal-install-2.4"]}}+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.10.3","cabal-install-3.0"]}} - compiler: ghc-7.8.4- addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.8.4","cabal-install-2.4"]}}+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.8.4","cabal-install-3.0"]}} - compiler: ghc-7.6.3- addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.6.3","cabal-install-2.4"]}}+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.6.3","cabal-install-3.0"]}} - compiler: ghc-7.4.2- addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.4.2","cabal-install-2.4"]}}+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.4.2","cabal-install-3.0"]}} - compiler: ghc-head addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-head","cabal-install-head"]}}- env: GHCHEAD=true allow_failures: - compiler: ghc-head- - compiler: ghc-8.8.1 before_install: - HC=$(echo "/opt/$CC/bin/ghc" | sed 's/-/\//')+ - WITHCOMPILER="-w $HC" - HCPKG="$HC-pkg" - unset CC - CABAL=/opt/ghc/bin/cabal - CABALHOME=$HOME/.cabal - export PATH="$CABALHOME/bin:$PATH" - TOP=$(pwd)- - HCNUMVER=$(( $(${HC} --numeric-version|sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\1 * 10000 + \2 * 100 + \3/') ))+ - "HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')" - echo $HCNUMVER - CABAL="$CABAL -vnormal+nowrap+markoutput" - set -o pipefail@@ -93,11 +91,13 @@ - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]" - TEST=--enable-tests - BENCH=--enable-benchmarks- - GHCHEAD=${GHCHEAD-false}+ - HEADHACKAGE=false+ - if [ $HCNUMVER -gt 80801 ] ; then HEADHACKAGE=true ; fi - rm -f $CABALHOME/config - | echo "verbose: normal +nowrap +markoutput" >> $CABALHOME/config echo "remote-build-reporting: anonymous" >> $CABALHOME/config+ echo "write-ghc-environment-files: always" >> $CABALHOME/config echo "remote-repo-cache: $CABALHOME/packages" >> $CABALHOME/config echo "logs-dir: $CABALHOME/logs" >> $CABALHOME/config echo "world-file: $CABALHOME/world" >> $CABALHOME/config@@ -111,15 +111,14 @@ echo "repository hackage.haskell.org" >> $CABALHOME/config echo " url: http://hackage.haskell.org/" >> $CABALHOME/config - |- if $GHCHEAD; then+ if $HEADHACKAGE; then echo "allow-newer: $($HCPKG list --simple-output | sed -E 's/([a-zA-Z-]+)-[0-9.]+/*:\1/g')" >> $CABALHOME/config- - echo "repository head.hackage" >> $CABALHOME/config- echo " url: http://head.hackage.haskell.org/" >> $CABALHOME/config+ echo "repository head.hackage.ghc.haskell.org" >> $CABALHOME/config+ echo " url: https://ghc.gitlab.haskell.org/head.hackage/" >> $CABALHOME/config echo " secure: True" >> $CABALHOME/config- echo " root-keys: 07c59cb65787dedfaef5bd5f987ceb5f7e5ebf88b904bbd4c5cbdeb2ff71b740" >> $CABALHOME/config- echo " 2e8555dde16ebd8df076f1a8ef13b8f14c66bad8eafefd7d9e37d0ed711821fb" >> $CABALHOME/config- echo " 8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e" >> $CABALHOME/config+ echo " root-keys: 7541f32a4ccca4f97aea3b22f5e593ba2c0267546016b992dfadcd2fe944e55d" >> $CABALHOME/config+ echo " 26021a13b401500c8eb2761ca95c61f2d625bfef951b939a8124ed12ecf07329" >> $CABALHOME/config+ echo " f76d08be13e9a61a377a85e2fb63f4c5435d40f8feb3e12eb05905edb8cdea89" >> $CABALHOME/config echo " key-threshold: 3" >> $CABALHOME/config fi - cat $CABALHOME/config@@ -129,17 +128,16 @@ - rm -rf cabal.project cabal.project.local cabal.project.freeze - touch cabal.project - |- echo 'packages: "."' >> cabal.project+ echo "packages: ." >> cabal.project - |- echo "write-ghc-environment-files: always" >> cabal.project- - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | grep -vE -- '^(keys)$' | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"+ - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(keys)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done" - cat cabal.project || true - cat cabal.project.local || true - if [ -f "./configure.ac" ]; then (cd "." && autoreconf -i); fi- - ${CABAL} v2-freeze -w ${HC} ${TEST} ${BENCH} | color_cabal_output+ - ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH} | color_cabal_output - "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'" - rm cabal.project.freeze- - ${CABAL} v2-build -w ${HC} ${TEST} ${BENCH} --dep -j2 all | color_cabal_output+ - ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} --dep -j2 all | color_cabal_output script: - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX) # Packaging...@@ -147,24 +145,25 @@ # Unpacking... - mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/ - cd ${DISTDIR} || false- - find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;+ - find . -maxdepth 1 -type f -name '*.tar.gz' -exec tar -xvf '{}' \;+ - find . -maxdepth 1 -type f -name '*.tar.gz' -exec rm '{}' \;+ - PKGDIR_keys="$(find . -maxdepth 1 -type d -regex '.*/keys-[0-9.]*')" # Generate cabal.project - rm -rf cabal.project cabal.project.local cabal.project.freeze - touch cabal.project - |- echo 'packages: "keys-*/*.cabal"' >> cabal.project+ echo "packages: ${PKGDIR_keys}" >> cabal.project - |- echo "write-ghc-environment-files: always" >> cabal.project- - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | grep -vE -- '^(keys)$' | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"+ - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(keys)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done" - cat cabal.project || true - cat cabal.project.local || true # Building with tests and benchmarks... # build & run tests, build benchmarks- - ${CABAL} v2-build -w ${HC} ${TEST} ${BENCH} all | color_cabal_output+ - ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output # cabal check...- - (cd keys-* && ${CABAL} -vnormal check)+ - (cd ${PKGDIR_keys} && ${CABAL} -vnormal check) # haddock...- - ${CABAL} v2-haddock -w ${HC} ${TEST} ${BENCH} all | color_cabal_output+ - ${CABAL} v2-haddock $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output # REGENDATA ["--output=.travis.yml","--config=cabal.haskell-ci","cabal.project"] # EOF
CHANGELOG.markdown view
@@ -1,3 +1,9 @@+3.12.3 [2020.01.29]+-------------------+* Add `Keyed`, `Indexable`, `Lookup`, `Adjustable`, `FoldableWithKey`, and+ `TraversableWithKey` instances for `Control.Applicative.Const` and+ `Data.Functor.Constant.Constant`.+ 3.12.2 [2019.05.02] ------------------- * Use more efficient implementations of `lookup`, `adjust`, `foldMapWithKey`,
keys.cabal view
@@ -1,6 +1,6 @@ name: keys category: Data Structures, Containers-version: 3.12.2+version: 3.12.3 license: BSD3 cabal-version: >= 1.10 license-file: LICENSE@@ -44,7 +44,7 @@ comonad >= 4 && < 6, containers >= 0.3 && < 0.7, free >= 4 && < 6,- hashable >= 1.1.2.3 && < 1.3,+ hashable >= 1.1.2.3 && < 1.4, semigroupoids >= 5.2 && < 6, semigroups >= 0.8.3.1 && < 1, tagged >= 0.7.3 && < 1,
src/Data/Key.hs view
@@ -75,6 +75,7 @@ import Data.Functor.Identity import Data.Functor.Bind import Data.Functor.Compose+import Data.Functor.Constant import Data.Functor.Product import qualified Data.Functor.Sum as Functor import Data.Foldable@@ -120,6 +121,8 @@ type instance Key Par1 = () type instance Key Proxy = Void type instance Key (Tagged a) = ()+type instance Key (Const e) = Void+type instance Key (Constant e) = Void type instance Key (g :.: f) = (Key g, Key f) type instance Key (f :*: g) = Either (Key f) (Key g) type instance Key (f :+: g) = Either (Key f) (Key g)@@ -159,6 +162,12 @@ instance Keyed Proxy where mapWithKey _ Proxy = Proxy +instance Keyed (Const e) where+ mapWithKey _ (Const a) = Const a++instance Keyed (Constant e) where+ mapWithKey _ (Constant a) = Constant a+ instance Keyed f => Keyed (M1 i c f) where mapWithKey q (M1 f) = M1 (mapWithKey q f) @@ -332,6 +341,12 @@ instance Indexable Proxy where index Proxy = absurd +instance Indexable (Const e) where+ index _ = absurd++instance Indexable (Constant e) where+ index _ = absurd+ instance Indexable Tree where index (Node a as) key = case viewl key of EmptyL -> a@@ -380,6 +395,12 @@ instance Lookup Proxy where lookup _ _ = Nothing +instance Lookup (Const e) where+ lookup _ _ = Nothing++instance Lookup (Constant e) where+ lookup _ _ = Nothing+ instance Lookup Tree where lookup key (Node a as) = case viewl key of EmptyL -> Just a@@ -451,6 +472,14 @@ adjust _ _ _ = Proxy replace _ _ _ = Proxy +instance Adjustable (Const e) where+ adjust _ _ x = x+ replace _ _ x = x++instance Adjustable (Constant e) where+ adjust _ _ x = x+ replace _ _ x = x+ instance Adjustable U1 where adjust _ _ _ = U1 replace _ _ _ = U1@@ -521,6 +550,12 @@ instance FoldableWithKey Proxy where foldMapWithKey _ _ = mempty +instance FoldableWithKey (Const e) where+ foldMapWithKey _ _ = mempty++instance FoldableWithKey (Constant e) where+ foldMapWithKey _ _ = mempty+ instance FoldableWithKey Tree where foldMapWithKey f (Node a as) = f Seq.empty a `mappend` foldMapWithKey (foldMapWithKey . fmap f . flip (|>)) as @@ -678,6 +713,12 @@ instance TraversableWithKey Proxy where traverseWithKey _ _ = pure Proxy +instance TraversableWithKey (Const e) where+ traverseWithKey _ (Const a) = pure (Const a)++instance TraversableWithKey (Constant e) where+ traverseWithKey _ (Constant a) = pure (Constant a)+ instance TraversableWithKey f => TraversableWithKey (Cofree f) where traverseWithKey f (a :< as) = (:<) <$> f Seq.empty a <*> traverseWithKey (traverseWithKey . fmap f . flip (|>)) as @@ -1121,7 +1162,7 @@ instance Adjustable Seq where - adjust f i xs = + adjust f i xs = #if MIN_VERSION_containers(0,5,8) Seq.adjust' f i xs -- Use the prefered strict version when available #else@@ -1131,7 +1172,7 @@ Just x -> let !x' = f x in Seq.update i x' xs #endif- + instance Keyed Seq where mapWithKey = Seq.mapWithIndex