GHC 9.4 regression: solveWanteds: too many iterations
(Originally spun out of a discussion at https://github.com/well-typed/generics-sop/issues/158.)
GHC 9.2 and earlier accept the following program:
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE UndecidableSuperClasses #-}
module Bug where
import Data.Kind (Constraint, Type)
data D a
f :: Generic (D a) => ()
f = ()
type family
AllF (c :: k -> Constraint) (xs :: [k]) :: Constraint where
AllF _c '[] = ()
AllF c (x ': xs) = (c x, All c xs)
class (AllF c xs, SListI xs) => All (c :: k -> Constraint) (xs :: [k]) where
type SListI = All Top
class Top x
instance Top x
class All SListI (Code a) => Generic a where
type Code a :: [[Type]]
GHC 9.4.3, however, rejects it with the following error message:
$ ghc-9.4.3 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:20:6: error:
* solveWanteds: too many iterations (limit = 4)
Unsolved: WC {wc_simple =
[W] irred_aEQ {0}:: AllF SListI (Code (D a0)) (CIrredCan(irred))
[W] irred_aEW {0}:: AllF Top (Code (D a0)) (CIrredCan(irred))
[W] $dGeneric_aEH {0}:: Generic (D a0) (CDictCan)
[W] $dAll_aEP {0}:: All SListI (Code (D a0)) (CDictCan)
[W] $dAll_aEX {0}:: All Top (Code (D a0)) (CDictCan(psc))}
Simples: {[W] irred_aEQ {0}:: AllF
SListI (Code (D a0)) (CIrredCan(irred)),
[W] irred_aEW {0}:: AllF Top (Code (D a0)) (CIrredCan(irred)),
[W] $dGeneric_aEH {0}:: Generic (D a0) (CDictCan),
[W] $dAll_aEP {0}:: All SListI (Code (D a0)) (CDictCan),
[W] $dAll_aEX {0}:: All Top (Code (D a0)) (CDictCan(psc))}
* In the type signature: f :: Generic (D a) => ()
Suggested fix:
Set limit with -fconstraint-solver-iterations=n; n=0 for no limit
|
20 | f :: Generic (D a) => ()
| ^^^^^^^^^^^^^^^^^^^
I've tried increasing the value of -fconstraint-solver-iterations
up to 1000
, but the error message persists.