fumieval / extensible

Extensible records, variants, structs, effects, tangles
BSD 3-Clause "New" or "Revised" License
128 stars 20 forks source link

Cannot build with hashable-1.4.0.0 #34

Closed matsubara0507 closed 3 years ago

matsubara0507 commented 3 years ago

When build extensible (0.8.3) with hashable-1.4.0.0, occur error:

[17 of 19] Compiling Data.Extensible.Dictionary

/path/to/extensible/src/Data/Extensible/Dictionary.hs:108:10: error:
    • Could not deduce (Forall (Instance1 Eq h) xs)
        arising from the superclasses of an instance declaration
      from the context: WrapForall Hashable h xs
        bound by the instance declaration
        at src/Data/Extensible/Dictionary.hs:108:10-55
    • In the instance declaration for ‘Hashable (xs :& h)’
    |                     
108 | instance WrapForall Hashable h xs => Hashable (xs :& h) where
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/path/to/extensible/src/Data/Extensible/Dictionary.hs:264:10: error:
    • Could not deduce (Forall (Instance1 Eq h) xs)
        arising from the superclasses of an instance declaration
      from the context: WrapForall Hashable h xs
        bound by the instance declaration
        at src/Data/Extensible/Dictionary.hs:264:10-55
    • In the instance declaration for ‘Hashable (xs :/ h)’
    |                     
264 | instance WrapForall Hashable h xs => Hashable (xs :/ h) where
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Completed 48 action(s).   

hashable is changed to add Eq constraint for Hashable class at version 1.4.0.0 https://github.com/haskell-unordered-containers/hashable/pull/202 So, I think need change to:

--- a/src/Data/Extensible/Dictionary.hs
+++ b/src/Data/Extensible/Dictionary.hs
@@ -105,7 +105,7 @@ instance (WrapForall Semigroup h xs, WrapForall Monoid h xs) => Monoid (xs :& h)
   mappend = (<>)
   {-# INLINE mappend #-}

-instance WrapForall Hashable h xs => Hashable (xs :& h) where
+instance (WrapForall Eq h xs, WrapForall Hashable h xs) => Hashable (xs :& h) where
   hashWithSalt = hfoldlWithIndexFor (Proxy :: Proxy (Instance1 Hashable h))
     (const hashWithSalt)
   {-# INLINE hashWithSalt #-}
@@ -261,7 +261,7 @@ instance WrapForall NFData h xs => NFData (xs :/ h) where
   rnf (EmbedAt i h) = views (pieceAt i) (\(Compose Dict) -> rnf h) (library :: xs :& Compose Dict (Instance1 NFData h))
   {-# INLINE rnf #-}

-instance WrapForall Hashable h xs => Hashable (xs :/ h) where
+instance (WrapForall Eq h xs, WrapForall Hashable h xs) => Hashable (xs :/ h) where
   hashWithSalt s (EmbedAt i h) = views (pieceAt i)
     (\(Compose Dict) -> s `hashWithSalt` i `hashWithSalt` h)
     (library :: xs :& Compose Dict (Instance1 Hashable h))