trace constraint failures when kind inference debug enabled

This commit is contained in:
Travis Staton 2023-11-17 16:33:16 -05:00
parent 30384f1468
commit 5571274311
No known key found for this signature in database
GPG Key ID: 431DD911A00DAE49

View File

@ -219,7 +219,7 @@ reduce cs0 = dbg "reduce" cs0 (go False [])
[] -> case b of
True -> dbg "go" acc (go False [])
False -> for acc \c ->
addConstraint c >>= \case
dbgSingle "failed to add constraint" c addConstraint >>= \case
Left x -> pure x
Right () -> error "impossible"
c : cs ->
@ -239,6 +239,19 @@ reduce cs0 = dbg "reduce" cs0 (go False [])
tracePretty (P.hang (P.bold hdr) (prettyConstraints ppe (map (review _Generated) cs))) (f cs)
False -> f cs
dbgSingle ::
forall a.
P.Pretty P.ColorText ->
GeneratedConstraint v loc ->
(GeneratedConstraint v loc -> Solve v loc a) ->
Solve v loc a
dbgSingle hdr c f =
case shouldDebug KindInference of
True -> do
ppe <- asks prettyPrintEnv
tracePretty (P.hang (P.bold hdr) (prettyConstraintD' ppe (review _Generated c))) (f c)
False -> f c
-- | Add a single constraint, returning an error if there is a
-- contradictory constraint
addConstraint ::