containers-tests: Enable -Werror for recent GHC versions
authorSimon Jakobi <simon.jakobi@gmail.com>
Sun, 29 Dec 2019 20:14:11 +0000 (21:14 +0100)
committerDavid Feuer <David.Feuer@gmail.com>
Sun, 29 Dec 2019 23:10:55 +0000 (18:10 -0500)
Also:
* Fix a bunch of warnings.
* Disable "cabal check" in Travis CI, since it dislikes -Werror

.travis.yml
cabal.haskell-ci
containers-tests/containers-tests.cabal
containers/src/Data/IntMap/Internal.hs
containers/src/Data/IntMap/Strict/Internal.hs
containers/src/Data/IntSet/Internal.hs

index 6fb6192..8309449 100644 (file)
@@ -4,9 +4,11 @@
 #
 # For more information, see https://github.com/haskell-CI/haskell-ci
 #
-# version: 0.3.20190413
+# version: 0.9.20191209
 #
+version: ~> 1.0
 language: c
+os: linux
 dist: xenial
 git:
   # whether to recursively clone submodules
@@ -18,6 +20,7 @@ cache:
   directories:
     - $HOME/.cabal/packages
     - $HOME/.cabal/store
+    - $HOME/.hlint
 before_cache:
   - rm -fv $CABALHOME/packages/hackage.haskell.org/build-reports.log
   # remove files that are regenerated by 'cabal update'
@@ -27,36 +30,40 @@ before_cache:
   - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar
   - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar.idx
   - rm -rfv $CABALHOME/packages/head.hackage
-matrix:
+jobs:
   include:
     - compiler: ghc-8.6.4
-      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.6.4","cabal-install-2.4"]}}
+      addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.6.4","cabal-install-3.0"]}}
+      os: linux
     - compiler: ghc-8.4.4
-      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.4.4","cabal-install-2.4"]}}
+      addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.4.4","cabal-install-3.0"]}}
+      os: linux
     - compiler: ghc-8.2.2
-      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.2.2","cabal-install-2.4"]}}
+      addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.2.2","cabal-install-3.0"]}}
+      os: linux
     - compiler: ghc-8.0.2
-      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.0.2","cabal-install-2.4"]}}
+      addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.0.2","cabal-install-3.0"]}}
+      os: linux
     - compiler: ghc-7.10.3
-      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.10.3","cabal-install-2.4"]}}
+      addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-7.10.3","cabal-install-3.0"]}}
+      os: linux
     - compiler: ghc-7.8.4
-      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.8.4","cabal-install-2.4"]}}
+      addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-7.8.4","cabal-install-3.0"]}}
+      os: linux
     - compiler: ghc-7.6.3
-      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.6.3","cabal-install-2.4"]}}
-    - compiler: ghc-head
-      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-head","cabal-install-head"]}}
-      env: GHCHEAD=true
-  allow_failures:
-    - compiler: ghc-head
+      addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-7.6.3","cabal-install-3.0"]}}
+      os: linux
 before_install:
   - HC=$(echo "/opt/$CC/bin/ghc" | sed 's/-/\//')
+  - WITHCOMPILER="-w $HC"
+  - HADDOCK=$(echo "/opt/$CC/bin/haddock" | sed 's/-/\//')
   - 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
@@ -83,35 +90,36 @@ install:
   - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
   - TEST=--enable-tests
   - BENCH=--enable-benchmarks
-  - if [ $HCNUMVER -lt 70804 ] ; then BENCH=--disable-benchmarks ; fi
-  - GHCHEAD=${GHCHEAD-false}
+  - if [ $HCNUMVER -lt 70800 ] ; then BENCH=--disable-benchmarks ; fi
+  - HEADHACKAGE=false
   - rm -f $CABALHOME/config
   - |
-    echo "verbose: normal +nowrap +markoutput"          >> $CABALHOME/config
-    echo "remote-build-reporting: anonymous"            >> $CABALHOME/config
-    echo "remote-repo-cache: $CABALHOME/packages"       >> $CABALHOME/config
-    echo "logs-dir:          $CABALHOME/logs"           >> $CABALHOME/config
-    echo "world-file:        $CABALHOME/world"          >> $CABALHOME/config
-    echo "extra-prog-path:   $CABALHOME/bin"            >> $CABALHOME/config
-    echo "symlink-bindir:    $CABALHOME/bin"            >> $CABALHOME/config
-    echo "build-summary:     $CABALHOME/logs/build.log" >> $CABALHOME/config
-    echo "store-dir:         $CABALHOME/store"          >> $CABALHOME/config
-    echo "install-dirs user"                            >> $CABALHOME/config
-    echo "  prefix: $CABALHOME"                         >> $CABALHOME/config
-    echo "repository hackage.haskell.org"               >> $CABALHOME/config
-    echo "  url: http://hackage.haskell.org/"           >> $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
+    echo "extra-prog-path:   $CABALHOME/bin"                                    >> $CABALHOME/config
+    echo "symlink-bindir:    $CABALHOME/bin"                                    >> $CABALHOME/config
+    echo "installdir:        $CABALHOME/bin"                                    >> $CABALHOME/config
+    echo "build-summary:     $CABALHOME/logs/build.log"                         >> $CABALHOME/config
+    echo "store-dir:         $CABALHOME/store"                                  >> $CABALHOME/config
+    echo "install-dirs user"                                                    >> $CABALHOME/config
+    echo "  prefix: $CABALHOME"                                                 >> $CABALHOME/config
+    echo "repository hackage.haskell.org"                                       >> $CABALHOME/config
+    echo "  url: http://hackage.haskell.org/"                                   >> $CABALHOME/config
+    echo "  secure: True"                                                       >> $CABALHOME/config
+    echo "  key-threshold: 3"                                                   >> $CABALHOME/config
+    echo "  root-keys:"                                                         >> $CABALHOME/config
+    echo "    fe331502606802feac15e514d9b9ea83fee8b6ffef71335479a2e68d84adc6b0" >> $CABALHOME/config
+    echo "    1ea9ba32c526d1cc91ab5e5bd364ec5e9e8cb67179a471872f6e26f0ae773d42" >> $CABALHOME/config
+    echo "    2c6c3627bd6c982990239487f1abd02e08a02e6cf16edb105a8012d444d870c3" >> $CABALHOME/config
+    echo "    0a5c7ea47cd1b15f01f5f51a33adda7e655bc0f0b0615baa8e271f4c3351e21d" >> $CABALHOME/config
+    echo "    51f0161b906011b52c6613376b1ae937670da69322113a246a09f807c62f6921" >> $CABALHOME/config
   - |
-    if $GHCHEAD; 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 "   secure: True"                                                                >> $CABALHOME/config
-    echo "   root-keys: 07c59cb65787dedfaef5bd5f987ceb5f7e5ebf88b904bbd4c5cbdeb2ff71b740" >> $CABALHOME/config
-    echo "              2e8555dde16ebd8df076f1a8ef13b8f14c66bad8eafefd7d9e37d0ed711821fb" >> $CABALHOME/config
-    echo "              8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e" >> $CABALHOME/config
-    echo "   key-threshold: 3"                                                            >> $CABALHOME/config
-    fi
+    echo "program-default-options"                >> $CABALHOME/config
+    echo "  ghc-options: $GHCJOBS +RTS -M6G -RTS" >> $CABALHOME/config
   - cat $CABALHOME/config
   - rm -fv cabal.project cabal.project.local cabal.project.freeze
   - travis_retry ${CABAL} v2-update -v
@@ -119,16 +127,15 @@ install:
   - rm -rf cabal.project cabal.project.local cabal.project.freeze
   - touch cabal.project
   - |
-    echo 'packages: "containers"' >> cabal.project
-    echo 'packages: "containers-tests"' >> cabal.project
+    echo "packages: containers" >> cabal.project
+    echo "packages: containers-tests" >> cabal.project
   - |
-    echo "write-ghc-environment-files: always" >> cabal.project
-  - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | grep -vE -- '^(binary|containers|containers-tests)$' | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
+  - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(binary|containers|containers-tests)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
   - cat cabal.project || true
   - cat cabal.project.local || true
   - if [ -f "containers/configure.ac" ]; then (cd "containers" && autoreconf -i); fi
   - if [ -f "containers-tests/configure.ac" ]; then (cd "containers-tests" && 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
 script:
@@ -138,34 +145,33 @@ script:
   # 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_containers="$(find . -maxdepth 1 -type d -regex '.*/containers-[0-9.]*')"
+  - PKGDIR_containers_tests="$(find . -maxdepth 1 -type d -regex '.*/containers-tests-[0-9.]*')"
   # Generate cabal.project
   - rm -rf cabal.project cabal.project.local cabal.project.freeze
   - touch cabal.project
   - |
-    echo 'packages: "containers-*/*.cabal"' >> cabal.project
-    echo 'packages: "containers-tests-*/*.cabal"' >> cabal.project
+    echo "packages: ${PKGDIR_containers}" >> cabal.project
+    echo "packages: ${PKGDIR_containers_tests}" >> cabal.project
   - |
-    echo "write-ghc-environment-files: always" >> cabal.project
-  - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | grep -vE -- '^(binary|containers|containers-tests)$' | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
+  - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(binary|containers|containers-tests)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
   - cat cabal.project || true
   - cat cabal.project.local || true
   # Building...
   # this builds all libraries and executables (without tests/benchmarks)
-  - ${CABAL} v2-build -w ${HC} --disable-tests --disable-benchmarks all | color_cabal_output
+  - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all | color_cabal_output
   # 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
   # Testing...
-  - ${CABAL} v2-test -w ${HC} ${TEST} ${BENCH} all | color_cabal_output
-  # cabal check...
-  - (cd containers-* && ${CABAL} -vnormal check)
-  - (cd containers-tests-* && ${CABAL} -vnormal check)
+  - ${CABAL} v2-test $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output
   # haddock...
-  - ${CABAL} v2-haddock -w ${HC} ${TEST} ${BENCH} all | color_cabal_output
+  - if [ $HCNUMVER -ge 80200 ] ; then ${CABAL} v2-haddock $WITHCOMPILER --with-haddock $HADDOCK ${TEST} ${BENCH} all | color_cabal_output ; fi
   # Building without installed constraints for packages in global-db...
   - rm -f cabal.project.local
-  - ${CABAL} v2-build -w ${HC} --disable-tests --disable-benchmarks all | color_cabal_output
+  - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all | color_cabal_output
 
-# REGENDATA ["--config=cabal.haskell-ci","cabal.project"]
+# REGENDATA ("0.9.20191209",["--config=cabal.haskell-ci","cabal.project"])
 # EOF
index 5d514b3..d4c0130 100644 (file)
@@ -12,3 +12,7 @@ installed: +all -binary
 
 -- gauge works only with newer GHC
 benchmarks: >=7.8.4
+
+haddock: >= 8.2
+
+cabal-check: False
index 8babc35..5be41e0 100644 (file)
@@ -91,6 +91,9 @@ library
       Data.Map.Internal.DeprecatedShowTree
       Utils.Containers.Internal.TypeError
 
+  if impl(ghc >= 8.6)
+    ghc-options: -Werror
+
 -----------------------------
 -- B E N C H M A R K I N G --
 -----------------------------
index b9238cc..5a5884d 100644 (file)
@@ -3201,7 +3201,7 @@ fromMonoListWithKey distinct f = go
 
     -- for `addAll` and `addMany`, kx is /a/ key inside the tree `tx`
     -- `addAll` consumes the rest of the list, adding to the tree `tx`
-    addAll !kx !tx []
+    addAll !_kx !tx []
         = tx
     addAll !kx !tx ((ky,vy) : zs)
         | m <- branchMask kx ky
@@ -3209,7 +3209,7 @@ fromMonoListWithKey distinct f = go
         = addAll kx (linkWithMask m ky ty {-kx-} tx) zs'
 
     -- `addMany'` is similar to `addAll'`, but proceeds with `addMany'`.
-    addMany' !m !kx vx []
+    addMany' !_m !kx vx []
         = Inserted (Tip kx vx) []
     addMany' !m !kx vx zs0@((ky,vy) : zs)
         | Nondistinct <- distinct, kx == ky
@@ -3222,7 +3222,7 @@ fromMonoListWithKey distinct f = go
         = addMany m kx (linkWithMask mxy ky ty {-kx-} (Tip kx vx)) zs'
 
     -- `addAll` adds to `tx` all keys whose prefix w.r.t. `m` agrees with `kx`.
-    addMany !m !kx tx []
+    addMany !_m !_kx tx []
         = Inserted tx []
     addMany !m !kx tx zs0@((ky,vy) : zs)
         | mask kx m /= mask ky m
index c1666e9..a3406d6 100644 (file)
@@ -1,5 +1,6 @@
 {-# LANGUAGE CPP #-}
 {-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE PatternGuards #-}
 
 #include "containers.h"
 
@@ -257,11 +258,8 @@ import qualified Data.IntMap.Internal as L
 import Data.IntMap.Internal
   ( IntMap (..)
   , Key
-  , Prefix
-  , Mask
   , mask
   , branchMask
-  , shorter
   , nomatch
   , zero
   , natFromInt
@@ -1148,8 +1146,6 @@ fromDistinctAscList :: [(Key,a)] -> IntMap a
 fromDistinctAscList = fromMonoListWithKey Distinct (\_ x _ -> x)
 {-# NOINLINE fromDistinctAscList #-}
 
-data Stack a = Push {-# UNPACK #-} !Prefix !(IntMap a) !(Stack a) | Nada
-
 -- | /O(n)/. Build a map from a list of key\/value pairs with monotonic keys
 -- and a combining function.
 --
@@ -1177,7 +1173,7 @@ fromMonoListWithKey distinct f = go
 
     -- for `addAll` and `addMany`, kx is /a/ key inside the tree `tx`
     -- `addAll` consumes the rest of the list, adding to the tree `tx`
-    addAll !kx !tx []
+    addAll !_kx !tx []
         = tx
     addAll !kx !tx ((ky,vy) : zs)
         | m <- branchMask kx ky
@@ -1185,7 +1181,7 @@ fromMonoListWithKey distinct f = go
         = addAll kx (linkWithMask m ky ty {-kx-} tx) zs'
 
     -- `addMany'` is similar to `addAll'`, but proceeds with `addMany'`.
-    addMany' !m !kx vx []
+    addMany' !_m !kx vx []
         = Inserted (Tip kx $! vx) []
     addMany' !m !kx vx zs0@((ky,vy) : zs)
         | Nondistinct <- distinct, kx == ky
@@ -1198,7 +1194,7 @@ fromMonoListWithKey distinct f = go
         = addMany m kx (linkWithMask mxy ky ty {-kx-} (Tip kx $! vx)) zs'
 
     -- `addAll` adds to `tx` all keys whose prefix w.r.t. `m` agrees with `kx`.
-    addMany !m !kx tx []
+    addMany !_m !_kx tx []
         = Inserted tx []
     addMany !m !kx tx zs0@((ky,vy) : zs)
         | mask kx m /= mask ky m
index 77c51c1..76b984f 100644 (file)
@@ -1,5 +1,6 @@
 {-# LANGUAGE CPP #-}
 {-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE PatternGuards #-}
 #if __GLASGOW_HASKELL__
 {-# LANGUAGE MagicHash, DeriveDataTypeable, StandaloneDeriving #-}
 #endif
@@ -217,11 +218,13 @@ import Text.Read
 #endif
 
 #if __GLASGOW_HASKELL__
-import GHC.Exts (Int(..), build)
+import GHC.Exts (build)
+#if !MIN_VERSION_base(4,8,0)
+import GHC.Exts (Int(..), indexInt8OffAddr#)
+#endif
 #if __GLASGOW_HASKELL__ >= 708
 import qualified GHC.Exts as GHCExts
 #endif
-import GHC.Exts (indexInt8OffAddr#)
 #endif
 
 import qualified Data.Foldable as Foldable
@@ -1110,7 +1113,7 @@ fromMonoList (kx : zs1) = addAll' (prefixOf kx) (bitmapOf kx) zs1
 
     -- for `addAll` and `addMany`, px is /a/ prefix inside the tree `tx`
     -- `addAll` consumes the rest of the list, adding to the tree `tx`
-    addAll !px !tx []
+    addAll !_px !tx []
         = tx
     addAll !px !tx (ky : zs)
         | py <- prefixOf ky
@@ -1119,7 +1122,7 @@ fromMonoList (kx : zs1) = addAll' (prefixOf kx) (bitmapOf kx) zs1
         = addAll px (linkWithMask m py ty {-px-} tx) zs'
 
     -- `addMany'` is similar to `addAll'`, but proceeds with `addMany'`.
-    addMany' !m !px !bm []
+    addMany' !_m !px !bm []
         = Inserted (Tip px bm) []
     addMany' !m !px !bm zs0@(ky : zs)
         | px == prefixOf ky
@@ -1133,7 +1136,7 @@ fromMonoList (kx : zs1) = addAll' (prefixOf kx) (bitmapOf kx) zs1
         = addMany m px (linkWithMask mxy py ty {-px-} (Tip px bm)) zs'
 
     -- `addAll` adds to `tx` all keys whose prefix w.r.t. `m` agrees with `px`.
-    addMany !m !px tx []
+    addMany !_m !_px tx []
         = Inserted tx []
     addMany !m !px tx zs0@(ky : zs)
         | mask px m /= mask ky m
@@ -1216,22 +1219,22 @@ orderingOf r = case r of
 -- | precondition: each argument is non-mixed
 relate :: IntSet -> IntSet -> Relation
 relate Nil Nil = Equals
-relate Nil t2 = Prefix
-relate t1 Nil = FlipPrefix
-relate t1@(Tip p1 bm1) t2@(Tip p2 bm2) = relateTipTip t1 t2
-relate t1@(Bin p1 m1 l1 r1) t2@(Bin p2 m2 l2 r2)
+relate Nil _t2 = Prefix
+relate _t1 Nil = FlipPrefix
+relate t1@Tip{} t2@Tip{} = relateTipTip t1 t2
+relate t1@(Bin _p1 m1 l1 r1) t2@(Bin _p2 m2 l2 r2)
   | succUpperbound t1 <= lowerbound t2 = Less
   | lowerbound t1 >= succUpperbound t2 = Greater
   | otherwise = case compare (natFromInt m1) (natFromInt m2) of
       GT -> combine_left (relate l1 t2)
       EQ -> combine (relate l1 l2) (relate r1 r2)
       LT -> combine_right (relate t1 l2)
-relate t1@(Bin p1 m1 l1 r1) t2@(Tip p2 _)
+relate t1@(Bin _p1 m1 l1 _r1) t2@(Tip p2 _bm2)
   | succUpperbound t1 <= lowerbound t2 = Less
   | lowerbound t1 >= succUpperbound t2 = Greater
   | 0 == (m1 .&. p2) = combine_left (relate l1 t2)
   | otherwise = Less
-relate t1@(Tip p1 _) t2@(Bin p2 m2 l2 r2)
+relate t1@(Tip p1 _bm1) t2@(Bin _p2 m2 l2 _r2)
   | succUpperbound t1 <= lowerbound t2 = Less
   | lowerbound t1 >= succUpperbound t2 = Greater
   | 0 == (p1 .&. m2) = combine_right (relate t1 l2)
@@ -1239,10 +1242,11 @@ relate t1@(Tip p1 _) t2@(Bin p2 m2 l2 r2)
 
 relateTipTip :: IntSet -> IntSet -> Relation
 {-# INLINE relateTipTip #-}
-relateTipTip t1@(Tip p1 bm1) t2@(Tip p2 bm2) = case compare p1 p2 of
+relateTipTip (Tip p1 bm1) (Tip p2 bm2) = case compare p1 p2 of
   LT -> Less
   EQ -> relateBM bm1 bm2
   GT -> Greater
+relateTipTip _ _ = error "relateTipTip"
 
 relateBM :: BitMap -> BitMap -> Relation
 {-# inline relateBM #-}
@@ -1299,6 +1303,7 @@ combine_right r = case r of
 -- | shall only be applied to non-mixed non-Nil trees
 lowerbound :: IntSet -> Int
 {-# INLINE lowerbound #-}
+lowerbound Nil = error "lowerbound: Nil"
 lowerbound (Tip p _) = p
 lowerbound (Bin p _ _ _) = p
 
@@ -1306,6 +1311,7 @@ lowerbound (Bin p _ _ _) = p
 -- shall only be applied to non-mixed non-Nil trees
 succUpperbound :: IntSet -> Int
 {-# INLINE succUpperbound #-}
+succUpperbound Nil = error "succUpperbound: Nil"
 succUpperbound (Tip p _) = p + wordSize 
 succUpperbound (Bin p m _ _) = p + shiftR m 1