morphismtech / squeal

Squeal, a deep embedding of SQL in Haskell
362 stars 32 forks source link

For ghc >= 9.4 use a fork of records-sop with relaxed bounds. #339

Closed philderbeast closed 1 year ago

philderbeast commented 1 year ago

A follow on from #335 for ghc-9.4.5.

Use a couple of alternate source-repository-package dependencies until records-sop is updated and published to hackage, see https://github.com/kosmikus/records-sop/issues/12.

$ cabal build all --enable-tests --enable-benchmarks
Cloning into '/.../dist-newstyle/src/records-s_-cc0a9700f9cd5a00'...
remote: Enumerating objects: 321, done.
remote: Counting objects: 100% (87/87), done.
remote: Compressing objects: 100% (46/46), done.
remote: Total 321 (delta 31), reused 63 (delta 20), pack-reused 234
Receiving objects: 100% (321/321), 61.90 KiB | 2.38 MiB/s, done.
Resolving deltas: 100% (137/137), done.
HEAD is now at db2d052 Bump stackage resolver to lts-20.18 for ghc-9.2.7.
Resolving dependencies...
Build profile: -w ghc-9.4.5 -O1
In order, the following will be built (use -v for more details):
 - squeal-postgresql-0.9.1.0 (lib) (first run)
 - squeal-postgresql-uuid-ossp-0.1.0.1 (lib) (first run)
 - squeal-postgresql-ltree-0.1.0.1 (lib) (first run)
 - squeal-postgresql-0.9.1.0 (test:spec) (first run)
 - squeal-postgresql-0.9.1.0 (test:properties) (first run)
 - squeal-postgresql-0.9.1.0 (bench:gauge) (first run)
 - squeal-postgresql-0.9.1.0 (exe:example) (first run)
Configuring library for squeal-postgresql-0.9.1.0..
Preprocessing library for squeal-postgresql-0.9.1.0..
Building library for squeal-postgresql-0.9.1.0..
...
[43 of 64] Compiling Squeal.PostgreSQL.Session.Monad

src/Squeal/PostgreSQL/Session/Monad.hs:112:40: warning: [-Wtype-equality-requires-operators]
    The use of ‘~’ without TypeOperators
    will become an error in a future GHC release.
    Suggested fix: Perhaps you intended to use TypeOperators
    |
112 |     :: (MonadTrans t, MonadPQ db m, pq ~ t m)
    |                                        ^

src/Squeal/PostgreSQL/Session/Monad.hs:222:40: warning: [-Wtype-equality-requires-operators]
    The use of ‘~’ without TypeOperators
    will become an error in a future GHC release.
    Suggested fix: Perhaps you intended to use TypeOperators
    |
222 |     :: (MonadTrans t, MonadPQ db m, pq ~ t m)
    | 
 ...
[53 of 64] Compiling Squeal.PostgreSQL.Session

src/Squeal/PostgreSQL/Session/Pool.hs:86:12: warning: [-Wdeprecations]
    In the use of ‘createPool’ (imported from Data.Pool):
    Deprecated: "Use newPool instead"
   |
86 |   liftIO $ createPool (connectdb conninfo) finish stripes idle maxResrc
   |
...
philderbeast commented 1 year ago

I've done more testing and found that compilation completes with ghc-9.4.5 and ghc-9.2.7 but with all of the following fails in the same way (and upping -fconstraint-solver-iterations doesn't help):

$ cabal repl squeal-postgresql
Resolving dependencies...
Build profile: -w ghc-9.4.1 -O1
...
src/Squeal/PostgreSQL/Expression/Type.hs:325:19: error:
    • solveWanteds: too many iterations (limit = 4)
        Unsolved: WC {wc_simple =
                        [W] irred_arzs {0}:: sop-core-0.5.0.2:Data.SOP.Constraint.AllF
                                               KnownNat ns0 (CIrredCan(irred))
                        [W] irred_arzy {0}:: sop-core-0.5.0.2:Data.SOP.Constraint.AllF
                                               SOP.Top ns0 (CIrredCan(irred))
                        [W] $dAll_arzz {0}:: SOP.All SOP.Top ns0 (CDictCan(psc))
                        [W] $dAll_arzl {0}:: SOP.All KnownNat ns0 (CDictCan)}
        Simples: {[W] irred_arzs {0}:: sop-core-0.5.0.2:Data.SOP.Constraint.AllF
                                         KnownNat ns0 (CIrredCan(irred)),
                  [W] irred_arzy {0}:: sop-core-0.5.0.2:Data.SOP.Constraint.AllF
                                         SOP.Top ns0 (CIrredCan(irred)),
                  [W] $dAll_arzz {0}:: SOP.All SOP.Top ns0 (CDictCan(psc)),
                  [W] $dAll_arzl {0}:: SOP.All KnownNat ns0 (CDictCan)}
    • In the type signature:
        renderDims :: forall ns. SOP.All KnownNat ns => ByteString
      In an equation for ‘fixarray’:
          fixarray ty
            = UnsafeTypeExpression $ renderSQL ty <> renderDims @dims
            where
                renderDims :: forall ns. SOP.All KnownNat ns => ByteString
                renderDims
                  = ("[" <>) . (<> "]") . intercalate "][" . SOP.hcollapse
                      $ SOP.hcmap
                          (SOP.Proxy @KnownNat) (SOP.K . fromString . show . natVal)
                          (SOP.hpure SOP.Proxy :: SOP.NP SOP.Proxy ns)
    Suggested fix:
      Set limit with -fconstraint-solver-iterations=n; n=0 for no limit
    |
325 |     renderDims :: forall ns. SOP.All KnownNat ns => ByteString
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
philderbeast commented 1 year ago

This is "GHC 9.4 regression: solveWanteds: too many iterations" ghc#22516 (discussed on generics-sop#158), fixed in ghc-9.4.5.