haskell-unordered-containers / unordered-containers

Efficient hashing-based container types
BSD 3-Clause "New" or "Revised" License
222 stars 97 forks source link

`unordered-containers-0.2.20` fails to build with `hashable < 1.4` #487

Open RyanGlScott opened 5 months ago

RyanGlScott commented 5 months ago

unordered-containers-0.2.20 fails to build when using a version of hashable older than 1.4.*:

$ cabal build --constraint="hashable<1.4" -w ghc-9.2
Build profile: -w ghc-9.2.8 -O1
In order, the following will be built (use -v for more details):
 - unordered-containers-0.2.20 (lib) (first run)
Preprocessing library for unordered-containers-0.2.20..
Building library for unordered-containers-0.2.20..
[4 of 9] Compiling Data.HashMap.Internal.Debug ( Data/HashMap/Internal/Debug.hs, /home/ryanscott/Documents/Hacking/Haskell/unordered-containers-0.2.20/dist-newstyle/build/x86_64-linux/ghc-9.2.8/unordered-containers-0.2.20/build/Data/HashMap/Internal/Debug.o, /home/ryanscott/Documents/Hacking/Haskell/unordered-containers-0.2.20/dist-newstyle/build/x86_64-linux/ghc-9.2.8/unordered-containers-0.2.20/build/Data/HashMap/Internal/Debug.dyn_o )

Data/HashMap/Internal/Debug.hs:99:15-27: error:
    • Could not deduce (Eq k) arising from a use of ‘validInternal’
      from the context: Hashable k
        bound by the type signature for:
                   valid :: forall k v. Hashable k => HashMap k v -> Validity k
        at Data/HashMap/Internal/Debug.hs:97:1-48
      Possible fix:
        add (Eq k) to the context of
          the type signature for:
            valid :: forall k v. Hashable k => HashMap k v -> Validity k
    • In the expression: validInternal initialSubHashPath t
      In an equation for ‘valid’:
          valid t
            = validInternal initialSubHashPath t
            where
                validInternal p Empty = Invalid INV1_internal_Empty p
                validInternal p (Leaf h l) = validHash p h <> validLeaf p h l
                validInternal p (Collision h ary)
                  = validHash p h <> validCollision p h ary
                validInternal p (BitmapIndexed b ary) = validBitmapIndexed p b ary
                validInternal p (Full ary) = validFull p ary
                validHash p h
                  | hashMatchesSubHashPath p h = Valid
                  | otherwise = Invalid (INV6_misplaced_hash h) p
                validLeaf p h (L k _)
                  | hash k == h = Valid
                  | otherwise = Invalid (INV7_key_hash_mismatch k h) p
                validCollision p h ary
                  = validCollisionSize
                      <> A.foldMap (validLeaf p h) ary <> distinctKeys
                  where
                      n = A.length ary
                      validCollisionSize
                        | n < 2 = Invalid (INV9_Collision_size n) p
                        | otherwise = Valid
                      ....
                ....
   |
99 | valid t     = validInternal initialSubHashPath t
   |               ^^^^^^^^^^^^^
Error: cabal: Failed to build unordered-containers-0.2.20.

unordered-containers-0.2.19.1 does not have this issue, based on my local testing.

HuwCampbell commented 5 months ago

I hit this one here. A package revision would seem to be in order.

treeowl commented 5 months ago

Oof. I should be able to do that today. I think we broke that comparability intentionally, but forgot to change the bound.

treeowl commented 5 months ago

Okay, I just published a Hackage revision. Let's keep this issue open to fix it properly.

HuwCampbell commented 5 months ago

Thanks.