From 0232aac0bafc2dda3f4dde6a0af8492bacb326db Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Tue, 20 Jun 2017 14:53:34 -0400 Subject: [PATCH 01/18] Use typeRepFingerprint from Type.Reflection.Unsafe typeRepFingerprint won't be exposed in Type.Reflection, but instead is available via Type.Reflection.Unsafe. --- Data/Hashable/Class.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Data/Hashable/Class.hs b/Data/Hashable/Class.hs index 651e89f..9e8ea89 100644 --- a/Data/Hashable/Class.hs +++ b/Data/Hashable/Class.hs @@ -110,7 +110,8 @@ import GHC.Generics #endif #if __GLASGOW_HASKELL__ >= 801 -import Type.Reflection (typeRepFingerprint, Typeable, TypeRep, SomeTypeRep(..)) +import Type.Reflection (Typeable, TypeRep, SomeTypeRep(..)) +import Type.Reflection.Unsafe (typeRepFingerprint) import GHC.Fingerprint.Type(Fingerprint(..)) #elif __GLASGOW_HASKELL__ >= 710 import Data.Typeable (typeRepFingerprint, Typeable, TypeRep) From 81527b2f5e66e432895c7058876a09484177c6f1 Mon Sep 17 00:00:00 2001 From: Johan Tibell Date: Thu, 22 Jun 2017 14:06:58 +1000 Subject: [PATCH 02/18] Bump version number to 1.2.6.1 --- CHANGES.md | 6 ++++++ hashable.cabal | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 22e40be..b938239 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,9 @@ +## Version 1.2.6.1 + + * Use typeRepFingerprint from Type.Reflection.Unsafe + + * Bump minimum version of base to 4.4. + ## Version 1.2.6.0 * Add support for type-indexed `Typeable`. diff --git a/hashable.cabal b/hashable.cabal index d186d9c..c782ea4 100644 --- a/hashable.cabal +++ b/hashable.cabal @@ -1,5 +1,5 @@ Name: hashable -Version: 1.2.6.0 +Version: 1.2.6.1 Synopsis: A class for types that can be converted to a hash value Description: This package defines a class, 'Hashable', for types that can be converted to a hash value. This class From e52ca16e030488f470bf33886fdfb3bb8981f41c Mon Sep 17 00:00:00 2001 From: George Wilson Date: Thu, 22 Jun 2017 16:52:04 +1000 Subject: [PATCH 03/18] Add cabal sandbox and new-build artifacts to .gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 0400e82..e1ccb1e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,8 @@ +.cabal-sandbox/ +cabal.project.local +cabal.sandbox.config dist +/dist-newstyle/ *.o *.hi From 6e85bbf23089ae14b6219a6c23e574e45925cd33 Mon Sep 17 00:00:00 2001 From: Ryan Scott Date: Thu, 6 Jul 2017 19:35:37 -0400 Subject: [PATCH 04/18] Add Hashable instance for Complex --- Data/Hashable/Class.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Data/Hashable/Class.hs b/Data/Hashable/Class.hs index 9e8ea89..91ee912 100644 --- a/Data/Hashable/Class.hs +++ b/Data/Hashable/Class.hs @@ -70,6 +70,7 @@ import Data.Bits (shiftL, shiftR, xor) import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString.Unsafe as B +import Data.Complex (Complex(..)) import Data.Int (Int8, Int16, Int32, Int64) import Data.List (foldl') import Data.Ratio (Ratio, denominator, numerator) @@ -439,6 +440,12 @@ instance Hashable Integer where inBounds x = x >= fromIntegral (minBound :: Int) && x <= maxInt #endif +instance Hashable a => Hashable (Complex a) where + {-# SPECIALIZE instance Hashable (Complex Double) #-} + {-# SPECIALIZE instance Hashable (Complex Float) #-} + hash (r :+ i) = hash r `hashWithSalt` i + hashWithSalt s (r :+ i) = s `hashWithSalt` r `hashWithSalt` i + #if MIN_VERSION_base(4,9,0) -- Starting with base-4.9, numerator/denominator don't need 'Integral' anymore instance Hashable a => Hashable (Ratio a) where From 7cd0802b78fe7f91cff79d41e95921ff2d9629ec Mon Sep 17 00:00:00 2001 From: Ryan Scott Date: Thu, 6 Jul 2017 19:42:11 -0400 Subject: [PATCH 05/18] Add Hashable1 instance as well --- Data/Hashable/Class.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Data/Hashable/Class.hs b/Data/Hashable/Class.hs index 91ee912..a223ff0 100644 --- a/Data/Hashable/Class.hs +++ b/Data/Hashable/Class.hs @@ -444,7 +444,9 @@ instance Hashable a => Hashable (Complex a) where {-# SPECIALIZE instance Hashable (Complex Double) #-} {-# SPECIALIZE instance Hashable (Complex Float) #-} hash (r :+ i) = hash r `hashWithSalt` i - hashWithSalt s (r :+ i) = s `hashWithSalt` r `hashWithSalt` i + hashWithSalt = hashWithSalt1 +instance Hashable1 Complex where + liftHashWithSalt h s (r :+ i) = s `h` r `h` i #if MIN_VERSION_base(4,9,0) -- Starting with base-4.9, numerator/denominator don't need 'Integral' anymore From 32d4018b0ea8bd57061bfd69bf69b0dd89478743 Mon Sep 17 00:00:00 2001 From: Tim McGilchrist Date: Wed, 13 Sep 2017 09:35:56 +1000 Subject: [PATCH 06/18] Add GHC 8.2.1 to travis builds --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index d73846b..dec8b00 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,7 @@ env: - CABALVER=1.18 GHCVER=7.8.4 - CABALVER=1.22 GHCVER=7.10.3 - CABALVER=1.24 GHCVER=8.0.1 + - CABALVER=1.24 GHCVER=8.2.1 # - CABALVER=head GHCVER=head # - HPVER=2013.2.0.0 # - HPVER=2012.4.0.0 From 6f3e6f68eb274cad76ed24362b2c4b20242daedb Mon Sep 17 00:00:00 2001 From: Tim McGilchrist Date: Thu, 14 Sep 2017 07:57:17 +1000 Subject: [PATCH 07/18] GHC 8.2.1 should use Cabal 2.0 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dec8b00..d6a3cb0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ env: - CABALVER=1.18 GHCVER=7.8.4 - CABALVER=1.22 GHCVER=7.10.3 - CABALVER=1.24 GHCVER=8.0.1 - - CABALVER=1.24 GHCVER=8.2.1 + - CABALVER=2.0 GHCVER=8.2.1 # - CABALVER=head GHCVER=head # - HPVER=2013.2.0.0 # - HPVER=2012.4.0.0 From 3374fa8a0454caabef664a9222f1c96174b4aba6 Mon Sep 17 00:00:00 2001 From: Karl Millar Date: Wed, 10 Jan 2018 11:46:54 -0800 Subject: [PATCH 08/18] Fix undefined behavior (signed integer overflow) --- cbits/fnv.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cbits/fnv.c b/cbits/fnv.c index 5640b66..9595f99 100644 --- a/cbits/fnv.c +++ b/cbits/fnv.c @@ -36,8 +36,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * The FNV-1 hash description: http://isthe.com/chongo/tech/comp/fnv/ * The FNV-1 hash is public domain: http://isthe.com/chongo/tech/comp/fnv/#public_domain */ -long hashable_fnv_hash(const unsigned char* str, long len, long hash) { +long hashable_fnv_hash(const unsigned char* str, long len, long salt) { + unsigned long hash = salt; while (len--) { hash = (hash * 16777619) ^ *str++; } @@ -48,6 +49,6 @@ long hashable_fnv_hash(const unsigned char* str, long len, long hash) { /* Used for ByteArray#s. We can't treat them like pointers in native Haskell, but we can in unsafe FFI calls. */ -long hashable_fnv_hash_offset(const unsigned char* str, long offset, long len, long hash) { - return hashable_fnv_hash(str + offset, len, hash); +long hashable_fnv_hash_offset(const unsigned char* str, long offset, long len, long salt) { + return hashable_fnv_hash(str + offset, len, salt); } From f15cde904809fa17e296ac41012132eb2ef71207 Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Wed, 7 Mar 2018 20:18:48 +0100 Subject: [PATCH 09/18] Modernise Travis CI script --- .travis.yml | 226 +++++++++++++++++++++++-------------------------- hashable.cabal | 2 + 2 files changed, 107 insertions(+), 121 deletions(-) diff --git a/.travis.yml b/.travis.yml index d6a3cb0..99e5627 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,127 +1,111 @@ -# NB: don't set `language: haskell` here +# This Travis job script has been generated by a script via +# +# runghc make_travis_yml_2.hs '-o' '.travis.yml' '--no-cabal-check' 'hashable.cabal' +# +# For more information, see https://github.com/hvr/multi-ghc-travis +# +language: c +sudo: false + +git: + submodules: false # whether to recursively clone submodules + +cache: + directories: + - $HOME/.cabal/packages + - $HOME/.cabal/store + +before_cache: + - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log + # remove files that are regenerated by 'cabal update' + - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.* + - rm -fv $HOME/.cabal/packages/hackage.haskell.org/*.json + - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.cache + - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar + - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar.idx + + - rm -rfv $HOME/.cabal/packages/head.hackage + +matrix: + include: + - compiler: "ghc-7.2.2" + # env: TEST=--disable-tests BENCH=--disable-benchmarks + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.2.2], sources: [hvr-ghc]}} + - compiler: "ghc-7.4.2" + # env: TEST=--disable-tests BENCH=--disable-benchmarks + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.4.2], sources: [hvr-ghc]}} + - compiler: "ghc-7.6.3" + # env: TEST=--disable-tests BENCH=--disable-benchmarks + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.6.3], sources: [hvr-ghc]}} + - compiler: "ghc-7.8.4" + # env: TEST=--disable-tests BENCH=--disable-benchmarks + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.8.4], sources: [hvr-ghc]}} + - compiler: "ghc-7.10.3" + # env: TEST=--disable-tests BENCH=--disable-benchmarks + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.10.3], sources: [hvr-ghc]}} + - compiler: "ghc-8.0.2" + # env: TEST=--disable-tests BENCH=--disable-benchmarks + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.0.2], sources: [hvr-ghc]}} + - compiler: "ghc-8.2.2" + # env: TEST=--disable-tests BENCH=--disable-benchmarks + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.2], sources: [hvr-ghc]}} -# See also https://github.com/hvr/multi-ghc-travis for more information - -# The following lines enable several GHC versions and/or HP versions -# to be tested; often it's enough to test only against the last -# release of a major GHC version. Setting HPVER implictly sets -# GHCVER. Omit lines with versions you don't need/want testing for. -env: -# - CABALVER=1.22 GHCVER=6.12.3 -# - CABALVER=1.16 GHCVER=7.0.1 -# - CABALVER=1.16 GHCVER=7.0.2 -# - CABALVER=1.16 GHCVER=7.0.3 -# - CABALVER=1.16 GHCVER=7.0.4 -# - CABALVER=1.16 GHCVER=7.2.1 - - CABALVER=1.16 GHCVER=7.2.2 -# - CABALVER=1.16 GHCVER=7.4.1 - - CABALVER=1.16 GHCVER=7.4.2 -# - CABALVER=1.16 GHCVER=7.6.1 -# - CABALVER=1.16 GHCVER=7.6.2 - - CABALVER=1.18 GHCVER=7.6.3 -# - CABALVER=1.18 GHCVER=7.8.1 -# - CABALVER=1.18 GHCVER=7.8.2 - - CABALVER=1.18 GHCVER=7.8.4 - - CABALVER=1.22 GHCVER=7.10.3 - - CABALVER=1.24 GHCVER=8.0.1 - - CABALVER=2.0 GHCVER=8.2.1 -# - CABALVER=head GHCVER=head -# - HPVER=2013.2.0.0 -# - HPVER=2012.4.0.0 -# - HPVER=2012.2.0.0 -# - HPVER=2011.4.0.0 - -# Note: the distinction between `before_install` and `install` is not -# important. before_install: - - case "$HPVER" in - "") ;; - - "2014.2.0.0") - export CABALVER=1.18 ; - export GHCVER=7.8.3 ; - echo "constraints:async==2.0.1.5,attoparsec==0.10.4.0,case-insensitive==1.1.0.3,fgl==5.5.0.1,GLUT==2.5.1.1,GLURaw==1.4.0.1,haskell-src==1.0.1.6,hashable==1.2.2.0,html==1.0.1.2,HTTP==4000.2.10,HUnit==1.2.5.2,mtl==2.1.3.1,network==2.4.2.3,OpenGL==2.9.2.0,OpenGLRaw==1.5.0.0,parallel==3.2.0.4,parsec==3.1.5,primitive==0.5.2.1,QuickCheck==2.6,random==1.0.1.1,regex-base==0.93.2,regex-compat==0.95.1,regex-posix==0.95.2,split==0.2.2,stm==2.4.2,syb==0.4.1,text==1.1.0.0,transformers==0.3.0.0,unordered-containers==0.2.4.0,vector==0.10.9.1,xhtml==3000.2.1,zlib==0.5.4.1" > cabal.config ;; - - "2013.2.0.0") - export CABALVER=1.16 ; - export GHCVER=7.6.3 ; - echo "constraints:async==2.0.1.4,attoparsec==0.10.4.0,case-insensitive==1.0.0.1,cgi==3001.1.7.5,fgl==5.4.2.4,GLUT==2.4.0.0,GLURaw==1.3.0.0,haskell-src==1.0.1.5,hashable==1.1.2.5,html==1.0.1.2,HTTP==4000.2.8,HUnit==1.2.5.2,mtl==2.1.2,network==2.4.1.2,OpenGL==2.8.0.0,OpenGLRaw==1.3.0.0,parallel==3.2.0.3,parsec==3.1.3,QuickCheck==2.6,random==1.0.1.1,regex-base==0.93.2,regex-compat==0.95.1,regex-posix==0.95.2,split==0.2.2,stm==2.4.2,syb==0.4.0,text==0.11.3.1,transformers==0.3.0.0,unordered-containers==0.2.3.0,vector==0.10.0.1,xhtml==3000.2.1,zlib==0.5.4.1" > cabal.config ;; - - "2012.4.0.0") - export CABALVER=1.16 ; - export GHCVER=7.6.2 ; - echo "constraints:async==2.0.1.3,cgi==3001.1.7.4,fgl==5.4.2.4,GLUT==2.1.2.1,haskell-src==1.0.1.5,html==1.0.1.2,HTTP==4000.2.5,HUnit==1.2.5.1,mtl==2.1.2,network==2.3.1.0,OpenGL==2.2.3.1,parallel==3.2.0.3,parsec==3.1.3,QuickCheck==2.5.1.1,random==1.0.1.1,regex-base==0.93.2,regex-compat==0.95.1,regex-posix==0.95.2,split==0.2.1.1,stm==2.4,syb==0.3.7,text==0.11.2.3,transformers==0.3.0.0,vector==0.10.0.1,xhtml==3000.2.1,zlib==0.5.4.0" > cabal.config ;; - - "2012.2.0.0") - export CABALVER=1.16 ; - export GHCVER=7.4.1 ; - echo "constraints:cgi==3001.1.7.4,fgl==5.4.2.4,GLUT==2.1.2.1,haskell-src==1.0.1.5,html==1.0.1.2,HTTP==4000.2.3,HUnit==1.2.4.2,mtl==2.1.1,network==2.3.0.13,OpenGL==2.2.3.1,parallel==3.2.0.2,parsec==3.1.2,QuickCheck==2.4.2,random==1.0.1.1,regex-base==0.93.2,regex-compat==0.95.1,regex-posix==0.95.1,stm==2.3,syb==0.3.6.1,text==0.11.2.0,transformers==0.3.0.0,xhtml==3000.2.1,zlib==0.5.3.3" > cabal.config ;; - - "2011.4.0.0") - export CABALVER=1.16 ; - export GHCVER=7.0.4 ; - echo "constraints:cgi==3001.1.7.4,fgl==5.4.2.4,GLUT==2.1.2.1,haskell-src==1.0.1.4,html==1.0.1.2,HUnit==1.2.4.2,network==2.3.0.5,OpenGL==2.2.3.0,parallel==3.1.0.1,parsec==3.1.1,QuickCheck==2.4.1.1,regex-base==0.93.2,regex-compat==0.95.1,regex-posix==0.95.1,stm==2.2.0.1,syb==0.3.3,xhtml==3000.2.0.4,zlib==0.5.3.1,HTTP==4000.1.2,deepseq==1.1.0.2" > cabal.config ;; - - *) - export GHCVER=unknown ; - echo "unknown/invalid Haskell Platform requested" ; - exit 1 ;; - - esac + - HC=${CC} + - HCPKG=${HC/ghc/ghc-pkg} + - unset CC + - ROOTDIR=$(pwd) + - mkdir -p $HOME/.local/bin + - "PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$HOME/local/bin:$PATH" + - HCNUMVER=$(( $(${HC} --numeric-version|sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\1 * 10000 + \2 * 100 + \3/') )) + - echo $HCNUMVER - - travis_retry sudo add-apt-repository -y ppa:hvr/ghc - - travis_retry sudo apt-get update - - travis_retry sudo apt-get install cabal-install-$CABALVER ghc-$GHCVER - - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH - -# Benchmarks aren't built as installing their dependencies causes a -# dependency cycle. install: - - cabal --version - - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]" - - travis_retry cabal update -# - cabal install --only-dependencies --enable-tests - - cabal install --only-dependencies - -# Here starts the actual work to be performed for the package under -# test; any command which exits with a non-zero exit code causes the -# build to fail. + - cabal --version + - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]" + - BENCH=${BENCH---disable-benchmarks} + - TEST=${TEST---enable-tests} + - HADDOCK=${HADDOCK-true} + - INSTALLED=${INSTALLED-true} + - GHCHEAD=${GHCHEAD-false} + - travis_retry cabal update -v + - "sed -i.bak 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config" + - rm -fv cabal.project cabal.project.local + - grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$' + - "printf 'packages: \".\"\\n' > cabal.project" + - cat cabal.project + - if [ -f "./configure.ac" ]; then + (cd "." && autoreconf -i); + fi + - rm -f cabal.project.freeze + - cabal new-build -w ${HC} ${TEST} ${BENCH} --project-file="cabal.project" --dep -j2 all + - cabal new-build -w ${HC} --disable-tests --disable-benchmarks --project-file="cabal.project" --dep -j2 all + - rm -rf .ghc.environment.* "."/dist + - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX) + +# Here starts the actual work to be performed for the package under test; +# any command which exits with a non-zero exit code causes the build to fail. script: - - if [ -f configure.ac ]; then autoreconf -i; fi - # -v2 provides useful information for debugging -# - cabal configure --enable-tests -v2 - - cabal configure -v2 - - # this builds all libraries and executables - # (including tests/benchmarks) - - cabal build - -# - cabal test - - cabal check - - # tests that a source-distribution can be generated - - cabal sdist - - # check that the generated source-distribution can be built & installed - - export SRC_TGZ=$(cabal info . | awk '{print $2 ".tar.gz";exit}') ; - cd dist/; - if [ -f "$SRC_TGZ" ]; then - cabal install --force-reinstalls "$SRC_TGZ"; - else - echo "expected '$SRC_TGZ' not found"; - exit 1; - fi; - cd ../ - - # Try to compile tests and benchmarks, run tests - # For some reason doesn't work with old cabal - # - # Disable tests on GHC 7.6.3 and 7.8.4, as there's something weird happening - # because of -inplace and globally installed hashable - - if [ ! $CABALVER = "1.16" -a ! $GHCVER = "7.6.3" -a ! $GHCVER = "7.8.4" ]; then - cabal install HUnit QuickCheck criterion random siphash test-framework test-framework-hunit test-framework-quickcheck2; - cabal configure -v2 --enable-tests --enable-benchmarks; - cabal test; - fi - + # test that source-distributions can be generated + - (cd "." && cabal sdist) + - mv "."/dist/hashable-*.tar.gz ${DISTDIR}/ + - cd ${DISTDIR} || false + - find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \; + - "printf 'packages: hashable-*/*.cabal\\n' > cabal.project" + - cat cabal.project + # this builds all libraries and executables (without tests/benchmarks) + - cabal new-build -w ${HC} --disable-tests --disable-benchmarks all + + # Build with installed constraints for packages in global-db + - if $INSTALLED; then echo cabal new-build -w ${HC} --disable-tests --disable-benchmarks $(${HCPKG} list --global --simple-output --names-only | sed 's/\([a-zA-Z0-9-]\{1,\}\) */--constraint="\1 installed" /g') all | sh; else echo "Not building with installed constraints"; fi + + # build & run tests, build benchmarks + - cabal new-build -w ${HC} ${TEST} ${BENCH} all + - if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} ${BENCH} all; fi + + # haddock + - rm -rf ./dist-newstyle + - if $HADDOCK; then cabal new-haddock -w ${HC} ${TEST} ${BENCH} all; else echo "Skipping haddock generation";fi + +# REGENDATA ["-o",".travis.yml","--no-cabal-check","hashable.cabal"] # EOF diff --git a/hashable.cabal b/hashable.cabal index c782ea4..204b1c8 100644 --- a/hashable.cabal +++ b/hashable.cabal @@ -19,6 +19,8 @@ Build-type: Simple Cabal-version: >=1.8 -- tests/Properties.hs shouldn't have to go here, but the source files -- for the test-suite stanzas don't get picked up by `cabal sdist`. +tested-with: GHC==8.2.2, GHC==8.0.2, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2, GHC==7.2.2 + Extra-source-files: CHANGES.md, README.md, tests/Properties.hs, benchmarks/Benchmarks.hs, benchmarks/cbits/*.c, benchmarks/cbits/*.h From f784d8c21c8b3a63f1033faa1d218dd07bc28c87 Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Wed, 7 Mar 2018 20:24:52 +0100 Subject: [PATCH 10/18] Add GHC 8.4.1 to build-matrix and update bounds --- .travis.yml | 3 +++ hashable.cabal | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 99e5627..61abdb1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,6 +49,9 @@ matrix: - compiler: "ghc-8.2.2" # env: TEST=--disable-tests BENCH=--disable-benchmarks addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.2], sources: [hvr-ghc]}} + - compiler: "ghc-8.4.1" + # env: TEST=--disable-tests BENCH=--disable-benchmarks + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.4.1], sources: [hvr-ghc]}} before_install: - HC=${CC} diff --git a/hashable.cabal b/hashable.cabal index 204b1c8..acd8ced 100644 --- a/hashable.cabal +++ b/hashable.cabal @@ -19,7 +19,7 @@ Build-type: Simple Cabal-version: >=1.8 -- tests/Properties.hs shouldn't have to go here, but the source files -- for the test-suite stanzas don't get picked up by `cabal sdist`. -tested-with: GHC==8.2.2, GHC==8.0.2, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2, GHC==7.2.2 +tested-with: GHC==8.4.1, GHC==8.2.2, GHC==8.0.2, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2, GHC==7.2.2 Extra-source-files: CHANGES.md, README.md, tests/Properties.hs, @@ -48,9 +48,9 @@ Library Exposed-modules: Data.Hashable Data.Hashable.Lifted Other-modules: Data.Hashable.Class - Build-depends: base >= 4.4 && < 4.11, + Build-depends: base >= 4.4 && < 4.12, bytestring >= 0.9 && < 0.11, - deepseq >= 1.3 + deepseq >= 1.3 && < 1.5 if impl(ghc) Build-depends: ghc-prim, text >= 0.11.0.5 From b5e915497c0fbc99bf05b2ed3c3d906bf99eebc0 Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Wed, 7 Mar 2018 22:03:23 +0100 Subject: [PATCH 11/18] Remove now redundant import The last reference to shiftR got removed in 634f49490ed4c438ac80828592515dad6392e166 --- Data/Hashable/Generic.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/Data/Hashable/Generic.hs b/Data/Hashable/Generic.hs index 3e8fe65..60065b2 100644 --- a/Data/Hashable/Generic.hs +++ b/Data/Hashable/Generic.hs @@ -18,7 +18,6 @@ module Data.Hashable.Generic ( ) where -import Data.Bits (shiftR) import Data.Hashable.Class import GHC.Generics From d7dd44034fd94a327222acc7bd27d6840c4eac13 Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Wed, 7 Mar 2018 22:11:01 +0100 Subject: [PATCH 12/18] Update spec-version of .cabal file Since hashable requires GHC 7.2+ / base >= 4.4, this implies Cabal 1.12 or later, so let's update the spec-version (and use the new-style spec version declaration while at it) and pin down to the Haskell2010 semantics. --- hashable.cabal | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hashable.cabal b/hashable.cabal index acd8ced..1286362 100644 --- a/hashable.cabal +++ b/hashable.cabal @@ -1,3 +1,4 @@ +Cabal-version: 1.12 Name: hashable Version: 1.2.6.1 Synopsis: A class for types that can be converted to a hash value @@ -16,7 +17,6 @@ bug-reports: https://github.com/tibbe/hashable/issues Stability: Provisional Category: Data Build-type: Simple -Cabal-version: >=1.8 -- tests/Properties.hs shouldn't have to go here, but the source files -- for the test-suite stanzas don't get picked up by `cabal sdist`. tested-with: GHC==8.4.1, GHC==8.2.2, GHC==8.0.2, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2, GHC==7.2.2 @@ -73,6 +73,8 @@ Library if os(windows) extra-libraries: advapi32 + Default-Language: Haskell2010 + Test-suite tests Type: exitcode-stdio-1.0 Hs-source-dirs: tests @@ -98,6 +100,8 @@ Test-suite tests if impl(ghc >= 7.2.1) CPP-Options: -DGENERICS + Default-Language: Haskell2010 + benchmark benchmarks -- We cannot depend on the hashable library directly as that creates -- a dependency cycle. @@ -159,6 +163,7 @@ benchmark benchmarks if os(windows) extra-libraries: advapi32 + Default-Language: Haskell2010 Executable hashable-examples if flag(examples) @@ -167,6 +172,7 @@ Executable hashable-examples buildable: False hs-source-dirs: examples main-is: Main.hs + Default-Language: Haskell2010 source-repository head type: git From cef18b5ad91c6f8e4f752c60ba9e35dfd78e1c49 Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Wed, 7 Mar 2018 22:33:22 +0100 Subject: [PATCH 13/18] Add changelog entry for upcoming 1.2.7.0 release --- CHANGES.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index b938239..34b06b7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,10 @@ +## Version 1.2.7.0 + + * Add `Hashable` and `Hashable1` instances for `Complex` + + * Fix undefined behavior in `hashable_fn_hash()` implementation + due to signed integer overflow (#152) + ## Version 1.2.6.1 * Use typeRepFingerprint from Type.Reflection.Unsafe From 12f67d1df8379a6680ac27e1d76d33f67ced001d Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Wed, 7 Mar 2018 22:38:45 +0100 Subject: [PATCH 14/18] Mark `Data.Hashable.Lifted` as `Trustworthy` (re SafeHaskell) `Data.Hashable` has been Trustworthy since 2013 (c.f. 7d56ac193a163328be38d4c137491560058745d4); when `Data.Hashable.Lifted` was added, giving it the same treatment was missed. --- CHANGES.md | 2 ++ Data/Hashable/Lifted.hs | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 34b06b7..4da72f0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,8 @@ * Fix undefined behavior in `hashable_fn_hash()` implementation due to signed integer overflow (#152) + * Mark `Data.Hashable.Lifted` as `Trustworthy` (re SafeHaskell) + ## Version 1.2.6.1 * Use typeRepFingerprint from Type.Reflection.Unsafe diff --git a/Data/Hashable/Lifted.hs b/Data/Hashable/Lifted.hs index e477518..6e6f5b2 100644 --- a/Data/Hashable/Lifted.hs +++ b/Data/Hashable/Lifted.hs @@ -1,3 +1,8 @@ +{-# LANGUAGE CPP #-} +#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702 +{-# LANGUAGE Trustworthy #-} +#endif + ------------------------------------------------------------------------ -- | -- Module : Data.Hashable.Class From 3eaabe67b66999fb9a545d24b6c5cf3dff37dbb2 Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Wed, 7 Mar 2018 22:45:28 +0100 Subject: [PATCH 15/18] Fix typo in module header comment --- Data/Hashable/Lifted.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Data/Hashable/Lifted.hs b/Data/Hashable/Lifted.hs index 6e6f5b2..ec38e3a 100644 --- a/Data/Hashable/Lifted.hs +++ b/Data/Hashable/Lifted.hs @@ -5,7 +5,7 @@ ------------------------------------------------------------------------ -- | --- Module : Data.Hashable.Class +-- Module : Data.Hashable.Lifted -- Copyright : (c) Milan Straka 2010 -- (c) Johan Tibell 2011 -- (c) Bryan O'Sullivan 2011, 2012 From 48428ada64817bf53644564679b15b40124877cc Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Wed, 7 Mar 2018 22:48:10 +0100 Subject: [PATCH 16/18] Bump version to 1.2.7.0 for release Only benign API additions were performed since 1.2.6.1, hence a minor version bump is adequate. --- CHANGES.md | 2 ++ hashable.cabal | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 4da72f0..48890b7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,8 @@ * Mark `Data.Hashable.Lifted` as `Trustworthy` (re SafeHaskell) + * Support GHC 8.4 + ## Version 1.2.6.1 * Use typeRepFingerprint from Type.Reflection.Unsafe diff --git a/hashable.cabal b/hashable.cabal index 1286362..74f6512 100644 --- a/hashable.cabal +++ b/hashable.cabal @@ -1,6 +1,6 @@ Cabal-version: 1.12 Name: hashable -Version: 1.2.6.1 +Version: 1.2.7.0 Synopsis: A class for types that can be converted to a hash value Description: This package defines a class, 'Hashable', for types that can be converted to a hash value. This class From 8122afdf1457fa048ba44eab4087fda98d68501d Mon Sep 17 00:00:00 2001 From: George Wilson Date: Wed, 4 Jul 2018 15:10:52 +1000 Subject: [PATCH 17/18] Relax base upper bound to build on GHC 8.6 --- hashable.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hashable.cabal b/hashable.cabal index 74f6512..3964e78 100644 --- a/hashable.cabal +++ b/hashable.cabal @@ -48,7 +48,7 @@ Library Exposed-modules: Data.Hashable Data.Hashable.Lifted Other-modules: Data.Hashable.Class - Build-depends: base >= 4.4 && < 4.12, + Build-depends: base >= 4.4 && < 4.13, bytestring >= 0.9 && < 0.11, deepseq >= 1.3 && < 1.5 if impl(ghc) From 9d27df1e13ade1e71c5dc54a5a9d8669491be8d5 Mon Sep 17 00:00:00 2001 From: George Wilson Date: Thu, 5 Jul 2018 09:01:04 +1000 Subject: [PATCH 18/18] Regenerate .travis.yml --- .travis.yml | 75 +++++++++++++++++++++++++++++++++++--------------- hashable.cabal | 2 +- 2 files changed, 54 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index 61abdb1..a7e0aba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,30 +28,36 @@ before_cache: matrix: include: - - compiler: "ghc-7.2.2" - # env: TEST=--disable-tests BENCH=--disable-benchmarks - addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.2.2], sources: [hvr-ghc]}} - - compiler: "ghc-7.4.2" + - compiler: "ghc-8.6.1" + env: GHCHEAD=true + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.6.1], sources: [hvr-ghc]}} + - compiler: "ghc-8.4.3" # env: TEST=--disable-tests BENCH=--disable-benchmarks - addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.4.2], sources: [hvr-ghc]}} - - compiler: "ghc-7.6.3" + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-8.4.3], sources: [hvr-ghc]}} + - compiler: "ghc-8.2.2" # env: TEST=--disable-tests BENCH=--disable-benchmarks - addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.6.3], sources: [hvr-ghc]}} - - compiler: "ghc-7.8.4" + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-8.2.2], sources: [hvr-ghc]}} + - compiler: "ghc-8.0.2" # env: TEST=--disable-tests BENCH=--disable-benchmarks - addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.8.4], sources: [hvr-ghc]}} + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-8.0.2], sources: [hvr-ghc]}} - compiler: "ghc-7.10.3" # env: TEST=--disable-tests BENCH=--disable-benchmarks - addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.10.3], sources: [hvr-ghc]}} - - compiler: "ghc-8.0.2" + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-7.10.3], sources: [hvr-ghc]}} + - compiler: "ghc-7.8.4" # env: TEST=--disable-tests BENCH=--disable-benchmarks - addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.0.2], sources: [hvr-ghc]}} - - compiler: "ghc-8.2.2" + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-7.8.4], sources: [hvr-ghc]}} + - compiler: "ghc-7.6.3" # env: TEST=--disable-tests BENCH=--disable-benchmarks - addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.2], sources: [hvr-ghc]}} - - compiler: "ghc-8.4.1" + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-7.6.3], sources: [hvr-ghc]}} + - compiler: "ghc-7.4.2" + # env: TEST=--disable-tests BENCH=--disable-benchmarks + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-7.4.2], sources: [hvr-ghc]}} + - compiler: "ghc-7.2.2" # env: TEST=--disable-tests BENCH=--disable-benchmarks - addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.4.1], sources: [hvr-ghc]}} + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-7.2.2], sources: [hvr-ghc]}} + + allow_failures: + - compiler: "ghc-8.6.1" before_install: - HC=${CC} @@ -69,14 +75,36 @@ install: - BENCH=${BENCH---disable-benchmarks} - TEST=${TEST---enable-tests} - HADDOCK=${HADDOCK-true} - - INSTALLED=${INSTALLED-true} + - UNCONSTRAINED=${UNCONSTRAINED-true} + - NOINSTALLEDCONSTRAINTS=${NOINSTALLEDCONSTRAINTS-false} - GHCHEAD=${GHCHEAD-false} - travis_retry cabal update -v - "sed -i.bak 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config" - rm -fv cabal.project cabal.project.local + # Overlay Hackage Package Index for GHC HEAD: https://github.com/hvr/head.hackage + - | + if $GHCHEAD; then + sed -i 's/-- allow-newer: .*/allow-newer: *:base/' ${HOME}/.cabal/config + for pkg in $($HCPKG list --simple-output); do pkg=$(echo $pkg | sed 's/-[^-]*$//'); sed -i "s/allow-newer: /allow-newer: *:$pkg, /" ${HOME}/.cabal/config; done + + echo 'repository head.hackage' >> ${HOME}/.cabal/config + echo ' url: http://head.hackage.haskell.org/' >> ${HOME}/.cabal/config + echo ' secure: True' >> ${HOME}/.cabal/config + echo ' root-keys: 07c59cb65787dedfaef5bd5f987ceb5f7e5ebf88b904bbd4c5cbdeb2ff71b740' >> ${HOME}/.cabal/config + echo ' 2e8555dde16ebd8df076f1a8ef13b8f14c66bad8eafefd7d9e37d0ed711821fb' >> ${HOME}/.cabal/config + echo ' 8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e' >> ${HOME}/.cabal/config + echo ' key-threshold: 3' >> ${HOME}/.cabal.config + + grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$' + + cabal new-update head.hackage -v + fi - grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$' - "printf 'packages: \".\"\\n' > cabal.project" - - cat cabal.project + - touch cabal.project.local + - "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg | grep -vw -- hashable | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi" + - cat cabal.project || true + - cat cabal.project.local || true - if [ -f "./configure.ac" ]; then (cd "." && autoreconf -i); fi @@ -95,13 +123,13 @@ script: - cd ${DISTDIR} || false - find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \; - "printf 'packages: hashable-*/*.cabal\\n' > cabal.project" - - cat cabal.project + - touch cabal.project.local + - "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg | grep -vw -- hashable | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi" + - cat cabal.project || true + - cat cabal.project.local || true # this builds all libraries and executables (without tests/benchmarks) - cabal new-build -w ${HC} --disable-tests --disable-benchmarks all - # Build with installed constraints for packages in global-db - - if $INSTALLED; then echo cabal new-build -w ${HC} --disable-tests --disable-benchmarks $(${HCPKG} list --global --simple-output --names-only | sed 's/\([a-zA-Z0-9-]\{1,\}\) */--constraint="\1 installed" /g') all | sh; else echo "Not building with installed constraints"; fi - # build & run tests, build benchmarks - cabal new-build -w ${HC} ${TEST} ${BENCH} all - if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} ${BENCH} all; fi @@ -110,5 +138,8 @@ script: - rm -rf ./dist-newstyle - if $HADDOCK; then cabal new-haddock -w ${HC} ${TEST} ${BENCH} all; else echo "Skipping haddock generation";fi + # Build without installed constraints for packages in global-db + - if $UNCONSTRAINED; then rm -f cabal.project.local; echo cabal new-build -w ${HC} --disable-tests --disable-benchmarks all; else echo "Not building without installed constraints"; fi + # REGENDATA ["-o",".travis.yml","--no-cabal-check","hashable.cabal"] # EOF diff --git a/hashable.cabal b/hashable.cabal index 3964e78..db26629 100644 --- a/hashable.cabal +++ b/hashable.cabal @@ -19,7 +19,7 @@ Category: Data Build-type: Simple -- tests/Properties.hs shouldn't have to go here, but the source files -- for the test-suite stanzas don't get picked up by `cabal sdist`. -tested-with: GHC==8.4.1, GHC==8.2.2, GHC==8.0.2, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2, GHC==7.2.2 +tested-with: GHC==8.6.1, GHC==8.4.3, GHC==8.2.2, GHC==8.0.2, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2, GHC==7.2.2 Extra-source-files: CHANGES.md, README.md, tests/Properties.hs,