beam icon indicating copy to clipboard operation
beam copied to clipboard

Constraint solver fails with ghc 8.4.3

Open dbaynard opened this issue 7 years ago • 2 comments

I've just been upgrading a project to ghc 8.4.3, and encountered the following error (full error below):

solvedWanteds: too many iterations (limit = 4)
New deriveds found
      Set limit with -fconstraint-solver-iterations=n; n=0 for no limit

The fix was to change

 getAllCurrentPunts' = orderBy_ (asc_ . view puntBookDate) .
-  filter_ (\p -> isNothing_ $ p ^. puntCancelled) .
-  all_ $ theDb ^. thedbPunts
+  filter_ (\p -> isNothing_ $ p ^. puntCancelled) $
+  getAllPunts'
+
+getAllPunts' = all_ $ theDb ^. thedbPunts

I had no idea what was happening. This was not the only case where it happened, but I had other places in the code where I was using all_ $ theDb ^. thedbPunts inline and they were not affected. For example,

getPuntsByUser' uid = select .
  whenUser uid .
  all_ $ theDb ^. thedbPunts

whenUser uid = filter_ (\p -> p ^. puntUser ==. val_ uid)

Using the lambda directly here did not cause the error.

Note: I'm not using any type signatures on queries or query fragments, and I have -XNoMonomorphismRestriction set.

    |
229 | getPuntCalendar = runSelectReturningPuntList . getPuntCalendar'
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/home/db/Projects/emmamcr/server/src/EmmaMCR/Database/Queries/Beam.lhs:240:1: error:
    solveWanteds: too many iterations (limit = 4)
      Unsolved: WC {wc_simple =
                      [WD] $dIsSql92SelectSyntax_a2HqH {0}∷ Database.Beam.Backend.SQL.SQL92.IsSql92SelectSyntax
                                                              syntax0 (CDictCan)
                      [W] $dMonadReader_a2Hw4 {0}∷ Control.Monad.Reader.Class.MonadReader
                                                     (PuntT
                                                        (QExpr
                                                           s0
                                                           (Database.Beam.Query.Internal.QNested
                                                              s2)))
                                                     ((->)
                                                        (PuntT
                                                           (QExpr
                                                              s1
                                                              (Database.Beam.Query.Internal.QNested
                                                                 s2)))) (CDictCan)
                      [WD] $dIsSql92OrderingSyntax_a2Hw5 {0}∷ Database.Beam.Backend.SQL.SQL92.IsSql92OrderingSyntax
                                                                s0 (CDictCan)
                      [W] $dSqlDeconstructMaybe_a2Hw6 {0}∷ SqlDeconstructMaybe
                                                             s1
                                                             (QGenExpr
                                                                QValueContext
                                                                s0
                                                                (Database.Beam.Query.Internal.QNested
                                                                   s2)
                                                                (Maybe LocalTime))
                                                             (QGenExpr
                                                                QValueContext
                                                                s1
                                                                (Database.Beam.Query.Internal.QNested
                                                                   s2)
                                                                LocalTime)
                                                             (Database.Beam.Query.Internal.QNested
                                                                s2) (CDictCan)
                      [WD] $dIsSql92FromSyntax_a2Hw7 {0}∷ Database.Beam.Backend.SQL.SQL92.IsSql92FromSyntax
                                                            s0 (CDictCan)
                      [WD] $dIsSql92TableSourceSyntax_a2Hwa {0}∷ Database.Beam.Backend.SQL.SQL92.IsSql92TableSourceSyntax
                                                                   s0 (CDictCan)
                      [D] _ {0}∷ Database.Beam.Backend.SQL.SQL92.IsSql92SelectTableSyntax
                                   s0 (CDictCan)
                      [D] _ {0}∷ Database.Beam.Backend.SQL.SQL92.IsSql92AggregationExpressionSyntax
                                   s0 (CDictCan)
                      [D] _ {0}∷ Database.Beam.Backend.SQL.SQL92.IsSql92ProjectionSyntax
                                   s0 (CDictCan)
                      [D] _ {1}∷ Database.Beam.Backend.SQL.SQL92.IsSql92ExpressionSyntax
                                   s0 (CDictCan)
                      [D] _ {0}∷ Database.Beam.Backend.SQL.SQL92.IsSql92ExpressionSyntax
                                   s0 (CDictCan)
                      [D] _ {0}∷ Database.Beam.Backend.SQL.SQL92.HasSqlValueSyntax
                                   s0 Int (CDictCan)
                      [D] _ {0}∷ Database.Beam.Backend.SQL.SQL92.HasSqlValueSyntax
                                   s0 Bool (CDictCan)
                      [D] _ {0}∷ Database.Beam.Backend.SQL.SQL92.HasSqlValueSyntax
                                   s0 Int (CDictCan)
                      [D] _ {0}∷ Database.Beam.Backend.SQL.SQL92.HasSqlValueSyntax
                                   s0 Bool (CDictCan)
                      [D] _ {0}∷ Database.Beam.Backend.SQL.SQL92.IsSql92FieldNameSyntax
                                   s0 (CDictCan)
                      [D] _ {0}∷ Database.Beam.Backend.SQL.SQL92.IsSql92FieldNameSyntax
                                   s0 (CDictCan)
                      [D] _ {0}∷ Database.Beam.Backend.SQL.SQL92.IsSql92QuantifierSyntax
                                   s0 (CDictCan)
                      [D] _ {0}∷ Database.Beam.Backend.SQL.SQL92.IsSql92QuantifierSyntax
                                   s0 (CDictCan)
                      [D] _ {0}∷ Typeable s0 (CDictCan)
                      [D] _ {0}∷ Typeable s0 (CDictCan)
                      [D] _ {0}∷ Database.Beam.Backend.SQL.SQL92.IsSql92GroupingSyntax
                                   s0 (CDictCan)
                      [D] _ {0}∷ Database.Beam.Backend.SQL.SQL92.IsSql92AggregationSetQuantifierSyntax
                                   s0 (CDictCan)
                      [D] _ {0}∷ Database.Beam.Backend.SQL.SQL92.IsSql92AggregationSetQuantifierSyntax
                                   s0 (CDictCan)
                      [D] _ {0}∷ Eq s0 (CDictCan)
                      [WD] hole{co_a2HvZ} {8}∷ s0 ~ s1 (CNonCanonical)
                      [D] _ {2}∷ s0 ~ s1 (CNonCanonical)
                      [WD] hole{co_a2HvW} {9}∷ s0 ~ s1 (CNonCanonical)
                      [D] _ {2}∷ s0 ~ s1 (CNonCanonical)
                      [D] _ {1}∷ Database.Beam.Backend.SQL.SQL92.HasSqlValueSyntax
                                   (Database.Beam.Backend.SQL.SQL92.Sql92ExpressionValueSyntax s0)
                                   Int (CDictCan)
                      [D] _ {1}∷ Database.Beam.Backend.SQL.SQL92.HasSqlValueSyntax
                                   (Database.Beam.Backend.SQL.SQL92.Sql92ExpressionValueSyntax s0)
                                   Bool (CDictCan)
                      [D] _ {1}∷ Database.Beam.Backend.SQL.SQL92.IsSql92FieldNameSyntax
                                   (Database.Beam.Backend.SQL.SQL92.Sql92ExpressionFieldNameSyntax
                                      s0) (CDictCan)
                      [D] _ {1}∷ Database.Beam.Backend.SQL.SQL92.IsSql92QuantifierSyntax
                                   (Database.Beam.Backend.SQL.SQL92.Sql92ExpressionQuantifierSyntax
                                      s0) (CDictCan)
                      [D] _ {1}∷ Typeable s0 (CDictCan)}
      New deriveds found
      Set limit with -fconstraint-solver-iterations=n; n=0 for no limit

(If you're curious: Punting )

dbaynard avatar Aug 12 '18 01:08 dbaynard

Hmm... this one is weird. Have you tried setting the constraint-solver-iterations higher (as the error says)? My guess is that this is a GHC configuration issue.

tathougies avatar Sep 24 '18 18:09 tathougies

Hello! Yes, I did (I don't remember the error that gave — I can dig it out if necessary). Were there any specifics that came to mind with the configuration issue?

dbaynard avatar Sep 24 '18 22:09 dbaynard