alt-romes / hegg

Fast equality saturation in Haskell
https://hackage.haskell.org/package/hegg
BSD 3-Clause "New" or "Revised" License
75 stars 8 forks source link

Build failures with various older GHCs #25

Closed phadej closed 1 year ago

phadej commented 1 year ago

I made a revision:

diff --git a/hegg.cabal b/hegg.cabal
index 3f6f9d8..e066481 100644
--- a/hegg.cabal
+++ b/hegg.cabal
@@ -46,6 +46,13 @@ source-repository head
     location: https://github.com/alt-romes/hegg

 library
+    other-extensions: BlockArguments StandaloneKindSignatures
+
+    -- QuantifiedConstraints are quite broken with GHC-9.0
+    -- Ord (Pattern l) instance triggers same issue like
+    -- https://github.com/haskell/mtl/issues/138
+    build-depends: base >=4.16  || <4.15
+
     ghc-options:      -Wall -Wcompat

                       -- -fno-prof-auto
@@ -91,7 +98,8 @@ library
     -- other-modules:

     -- LANGUAGE extensions used by modules in this package.
-    build-depends:    base         >= 4.4 && < 5,
+    -- base-4.13, because foldMap' is used.
+    build-depends:    base         >= 4.13 && < 5,
                       transformers >= 0.4 && < 0.7,
                       containers   >= 0.4 && < 0.7
     if flag(vizdot)

Due foldMap' definition you need at least GHC-8.10. StandaloneKindSignatures need GHC-8.8 IIRC.

The quantified constraints bug is unfortunate, but it's there to stay.

diff --git a/src/Data/Equality/Matching/Pattern.hs b/src/Data/Equality/Matching/Pattern.hs
index 3711831..41ac5b8 100644
--- a/src/Data/Equality/Matching/Pattern.hs
+++ b/src/Data/Equality/Matching/Pattern.hs
@@ -77,12 +77,12 @@ data Pattern lang
 pat :: lang (Pattern lang) -> Pattern lang
 pat = NonVariablePattern

-instance (∀ a. Eq a => Eq (l a)) => (Eq (Pattern l)) where
+instance (Eq (lang (Pattern lang))) => (Eq (Pattern lang)) where
     (==) (NonVariablePattern a) (NonVariablePattern b) = (==) a b
     (==) (VariablePattern a) (VariablePattern b) = a == b 
     (==) _ _ = False

-instance (∀ a. Eq a => Eq (l a), ∀ a. (Ord a) => Ord (l a)) => (Ord (Pattern l)) where
+instance (Ord (lang (Pattern lang))) => (Ord (Pattern lang)) where
     compare (VariablePattern _) (NonVariablePattern _) = LT
     compare (NonVariablePattern _) (VariablePattern _) = GT
     compare (VariablePattern a) (VariablePattern b) = compare a b

is an option to restore GHC-9.0 support, by simply not using QuantifiedConstraints.

I see you have CI setup, but as you test only with GHC-8.10.7, the base bound indeed should be updated to >=4.13. You skip 9.0 in CI, but your bounds allow it.

We drop support for 9.0.2 because quantified constraints seems buggy, or at least the ones we use don't compile successfully in 9.0.2

If you do so, please update your bounds too. tested-with is only an informative field, it doesn't constraint cabal-install solver e.g.

alt-romes commented 1 year ago

Thank you for revising this @phadej! I've merged the first proposed changes, not allowing 9.0, in 7e75faa0d67b24b2a89b55baf3c036e62c81caa2.