nikita-volkov / stm-hamt

STM-specialised Hash Array Mapped Trie
https://hackage.haskell.org/package/stm-hamt
MIT License
9 stars 6 forks source link

Could not deduce (Eq key) #6

Closed juhp closed 1 year ago

juhp commented 1 year ago

While trying to build the latest haskell-language-server for Fedora 37 (ghc-8.10.7) using cabal-install, I hit:

Building library for stm-hamt-1.2.0.10..
[1 of 9] Compiling StmHamt.Prelude  ( library/StmHamt/Prelude.hs, dist/build/StmHamt/Prelude.o, dist/build/StmHamt/Prelude.dyn_o )
[2 of 9] Compiling StmHamt.IntOps   ( library/StmHamt/IntOps.hs, dist/build/StmHamt/IntOps.o, dist/build/StmHamt/IntOps.dyn_o )
[3 of 9] Compiling StmHamt.Types    ( library/StmHamt/Types.hs, dist/build/StmHamt/Types.o, dist/build/StmHamt/Types.dyn_o )
[4 of 9] Compiling StmHamt.ListT    ( library/StmHamt/ListT.hs, dist/build/StmHamt/ListT.o, dist/build/StmHamt/ListT.dyn_o )
[5 of 9] Compiling StmHamt.Constructors.Branch ( library/StmHamt/Constructors/Branch.hs, dist/build/StmHamt/Constructors/Branch.o, dist/build/StmHamt/Constructors/Branch.dyn_o )
[6 of 9] Compiling StmHamt.Focuses  ( library/StmHamt/Focuses.hs, dist/build/StmHamt/Focuses.o, dist/build/StmHamt/Focuses.dyn_o )
[7 of 9] Compiling StmHamt.UnfoldlM ( library/StmHamt/UnfoldlM.hs, dist/build/StmHamt/UnfoldlM.o, dist/build/StmHamt/UnfoldlM.dyn_o )
[8 of 9] Compiling StmHamt.Hamt     ( library/StmHamt/Hamt.hs, dist/build/StmHamt/Hamt.o, dist/build/StmHamt/Hamt.dyn_o )
library/StmHamt/Hamt.hs:34:66: error:
    * Could not deduce (Eq key) arising from a use of `=='
      from the context: Hashable key
        bound by the type signature for:
                   focus :: forall key element result.
                            Hashable key =>
                            Focus element STM result
                            -> (element -> key) -> key -> Hamt element -> STM result
        at library/StmHamt/Hamt.hs:33:1-108
      Possible fix:
        add (Eq key) to the context of
          the type signature for:
            focus :: forall key element result.
                     Hashable key =>
                     Focus element STM result
                     -> (element -> key) -> key -> Hamt element -> STM result
    * In the first argument of `(.)', namely `(==) key'
      In the third argument of `focusExplicitly', namely
        `((==) key . elementToKey)'
      In the expression:
        focusExplicitly focus (hash key) ((==) key . elementToKey)
   |
34 | focus focus elementToKey key = focusExplicitly focus (hash key) ((==) key . elementToKey)
   |                                                                  ^^^^^^^^
library/StmHamt/Hamt.hs:47:36: error:
    * Could not deduce (Eq key) arising from a use of `=='
      from the context: Hashable key
        bound by the type signature for:
                   insert :: forall key element.
                             Hashable key =>
                             (element -> key) -> element -> Hamt element -> STM Bool
        at library/StmHamt/Hamt.hs:44:1-83
      Possible fix:
        add (Eq key) to the context of
          the type signature for:
            insert :: forall key element.
                      Hashable key =>
                      (element -> key) -> element -> Hamt element -> STM Bool
    * In the first argument of `(.)', namely `(==) key'
      In the second argument of `insertExplicitly', namely
        `((==) key . elementToKey)'
      In the expression:
        insertExplicitly (hash key) ((==) key . elementToKey) element
   |
47 |    in insertExplicitly (hash key) ((==) key . elementToKey) element
   |                                    ^^^^^^^^
library/StmHamt/Hamt.hs:100:56: error:
    * Could not deduce (Eq key) arising from a use of `=='
      from the context: Hashable key
        bound by the type signature for:
                   lookup :: forall key element.
                             Hashable key =>
                             (element -> key) -> key -> Hamt element -> STM (Maybe element)
        at library/StmHamt/Hamt.hs:99:1-90
      Possible fix:
        add (Eq key) to the context of
          the type signature for:
            lookup :: forall key element.
                      Hashable key =>
                      (element -> key) -> key -> Hamt element -> STM (Maybe element)
    * In the first argument of `(.)', namely `(==) key'
      In the second argument of `lookupExplicitly', namely
        `((==) key . elementToKey)'
      In the expression:
        lookupExplicitly (hash key) ((==) key . elementToKey)
    |
100 | lookup elementToKey key = lookupExplicitly (hash key) ((==) key . elementToKey)
    |                                                        ^^^^^^^^
Error: cabal: Failed to build stm-hamt-1.2.0.10 (which is required by
exe:haskell-language-server-wrapper from haskell-language-server-1.10.0.0 and
exe:haskell-language-server from haskell-language-server-1.10.0.0). See the
build log above for details.

https://download.copr.fedorainfracloud.org/results/petersen/haskell-language-server/fedora-37-x86_64/05749911-haskell-language-server/

juhp commented 1 year ago

stm-hamt-1.2.0.9 seemed to build okay in the same environment

Also the previous build logs: https://download.copr.fedorainfracloud.org/results/petersen/haskell-language-server/fedora-37-x86_64/05641745-haskell-language-server/

juhp commented 1 year ago

Just for reference/completeness here is a diff of the deps cabal-install built:

--- old.log 2023-04-06 19:11:52.546591587 +0800
+++ new.log 2023-04-06 19:12:39.327896785 +0800
@@ -1 +1 @@
- - alex-3.2.7.1 (exe:alex) (requires download & build)
+ - alex-3.2.7.2 (exe:alex) (requires download & build)
@@ -3 +2,0 @@
- - atomic-primops-0.8.4 (lib) (requires download & build)
@@ -12,2 +10,0 @@
- - czipwith-1.0.1.4 (lib) (requires download & build)
- - data-tree-print-0.1.0.2 (lib) (requires download & build)
@@ -21 +18 @@
- - focus-1.0.3 (lib) (requires download & build)
+ - focus-1.0.3.1 (lib) (requires download & build)
@@ -23 +19,0 @@
- - generic-lens-core-2.2.1.0 (lib) (requires download & build)
@@ -26 +21,0 @@
- - ghc-source-gen-0.4.3.0 (lib) (requires download & build)
@@ -29 +23,0 @@
- - hyphenation-0.8.2 (lib) (requires download & build)
@@ -33,2 +26,0 @@
- - monad-memo-0.5.4 (lib) (requires download & build)
- - multistate-0.8.0.4 (lib) (requires download & build)
@@ -38 +29,0 @@
- - refinery-0.4.0.0 (lib) (requires download & build)
@@ -45 +35,0 @@
- - strict-list-0.1.7 (lib) (requires download & build)
@@ -48,2 +37,0 @@
- - unsafe-0.0 (lib:unsafe) (requires download & build)
- - unagi-chan-0.4.1.4 (lib) (requires download & build)
@@ -60 +47,0 @@
- - generic-lens-2.2.1.0 (lib) (requires download & build)
@@ -65 +52 @@
- - monoid-subclasses-1.2.2 (lib) (requires download & build)
+ - monoid-subclasses-1.2.3 (lib) (requires download & build)
@@ -69 +55,0 @@
- - deque-0.4.4 (lib) (requires download & build)
@@ -72 +58 @@
- - hiedb-0.4.2.0 (lib) (requires download & build)
+ - hiedb-0.4.3.0 (lib) (requires download & build)
@@ -84 +69,0 @@
- - butcher-1.3.3.2 (lib) (requires download & build)
@@ -91 +76 @@
- - hie-bios-0.11.0 (lib) (requires download & build)
+ - hie-bios-0.12.0 (lib) (requires download & build)
@@ -95,2 +80 @@
- - brittany-0.13.1.2 (lib) (requires download & build)
- - stm-hamt-1.2.0.9 (lib) (requires download & build)
+ - stm-hamt-1.2.0.10 (lib) (requires download & build)
MangoIV commented 1 year ago

can reproduce this, for me it also got solved by specifying the older version.

jasagredo commented 1 year ago

This is exactly what would be solved with this PR I posted a while ago https://github.com/nikita-volkov/stm-hamt/pull/5

nikita-volkov commented 1 year ago

5 is now merged and will be released in a couple of minutes. Sorry for not responding earlier.

juhp commented 1 year ago

Btw how about adding a hackage link here to the top page?

juhp commented 1 year ago

(Haven't investigated but at least with ghc-8.10 cabal still seemed to choose the previous version for me when building hls, nvm)

juhp commented 1 year ago

Actually a revision of 1.2.0.10 would still be good

nikita-volkov commented 1 year ago

Btw how about adding a hackage link here to the top page?

Done.

Actually a revision of 1.2.0.10 would still be good

Not sure what you suggest here. Can you elaborate?

juhp commented 1 year ago

I mean a Hackage revision of stm-hamt.cabal for 1.2.0.10 to add the lowerbound for hashable. That's the only thing missing really :-)