@@ -36,7 +36,6 @@ import Data.Text (
3636 Text ,
3737 )
3838import Data.Text qualified as Text
39- import Data.Vector qualified as Vec
4039import Debug
4140import GHC.Generics qualified as GHC
4241import Generics.SOP qualified as SOP
@@ -48,7 +47,7 @@ import Kore.Attribute.SourceLocation (
4847 )
4948import Kore.Equation.Equation (Equation (.. ))
5049import Kore.Internal.OrCondition (OrCondition )
51- import Kore.Internal.Pattern (Conditional (.. ), Pattern )
50+ import Kore.Internal.Pattern (Conditional (.. ), Pattern , toTermLike )
5251import Kore.Internal.Predicate (Predicate )
5352import Kore.Internal.SideCondition (SideCondition )
5453import Kore.Internal.TermLike (
@@ -294,10 +293,14 @@ instance Entry DebugAttemptEquation where
294293 helpDoc _ = " log equation application attempts"
295294
296295 oneLineContextDoc = \ case
297- _entry@ DebugAttemptEquation {} -> [ " detail " ]
296+ _entry@ DebugAttemptEquation {} -> single CtxDetail
298297 (DebugAttemptEquationResult _ result) -> case result of
299- Right Conditional {term} -> [" success" , " term " <> (showHashHex $ hash term), " kore-term" ]
300- Left {} -> [" failure" ]
298+ Right Conditional {term} ->
299+ [ CLNullary CtxSuccess
300+ , CtxTerm `withShortId` showHashHex (hash term)
301+ , CLNullary CtxKoreTerm
302+ ]
303+ Left {} -> single CtxFailure
301304
302305 oneLineDoc (DebugAttemptEquation equation _term) =
303306 maybe
@@ -310,21 +313,6 @@ instance Entry DebugAttemptEquation where
310313 Right Conditional {term} -> " " <> unparse term
311314 Left failure -> " " <> Pretty. pretty (failureDescription failure)
312315
313- oneLineContextJson = \ case
314- _entry@ DebugAttemptEquation {} -> JSON. String " detail"
315- _entry@ (DebugAttemptEquationResult _equation result) ->
316- case result of
317- Right Conditional {term} ->
318- JSON. Array $
319- Vec. fromList
320- [ JSON. String " success"
321- , JSON. object
322- [ " term" JSON. .= showHashHex (hash term)
323- ]
324- , JSON. String " kore-term"
325- ]
326- Left _failure -> JSON. String " failure"
327-
328316 oneLineJson = \ case
329317 _entry@ (DebugAttemptEquation equation _term) ->
330318 JSON. toJSON $ renderDefault (maybe " UNKNOWN" pretty (srcLoc equation))
@@ -350,12 +338,7 @@ instance Entry DebugTermContext where
350338 oneLineDoc DebugTermContext {} = mempty
351339
352340 oneLineContextDoc (DebugTermContext term) =
353- [" term " <> (showHashHex $ hash term)]
354-
355- oneLineContextJson (DebugTermContext term) =
356- JSON. object
357- [ " term" JSON. .= showHashHex (hash term)
358- ]
341+ [CtxTerm `withShortId` showHashHex (hash term)]
359342
360343 oneLineJson :: DebugTermContext -> JSON. Value
361344 oneLineJson DebugTermContext {} =
@@ -366,13 +349,7 @@ instance Entry DebugTerm where
366349
367350 oneLineDoc (DebugTerm term) = unparse term
368351
369- oneLineContextDoc DebugTerm {} =
370- [" kore-term" ]
371-
372- oneLineContextJson DebugTerm {} =
373- JSON. toJSON
374- [ " kore-term" :: Text
375- ]
352+ oneLineContextDoc DebugTerm {} = single CtxKoreTerm
376353
377354 oneLineJson (DebugTerm term) =
378355 JSON. toJSON $ Kore.Syntax.Json. fromTermLike (getRewritingTerm term)
@@ -383,18 +360,9 @@ instance Entry DebugEquation where
383360 oneLineDoc _ = mempty
384361
385362 oneLineContextDoc (DebugEquation equation) =
386- let equationKindTxt = if isSimplification equation then " simplification" else " function"
387- in [ equationKindTxt <> " " <> shortRuleIdText equation
388- ]
389- oneLineContextJson (DebugEquation equation) =
390- let equationKindTxt = if isSimplification equation then " simplification" else " function"
391- in JSON. Array $
392- Vec. fromList
393- [ JSON. object
394- [ equationKindTxt
395- JSON. .= ruleIdText equation
396- ]
397- ]
363+ let equationKind = if isSimplification equation then CtxSimplification else CtxFunction
364+ in [equationKind `withId` ruleIdText equation]
365+
398366 oneLineJson _ = JSON. Null
399367
400368whileDebugTerm ::
@@ -485,7 +453,16 @@ instance Entry DebugApplyEquation where
485453 ]
486454 helpDoc _ = " log equation application successes"
487455
488- oneLineJson _ = JSON. Null
456+ oneLineContextDoc (DebugApplyEquation equation result) =
457+ let equationKind = if isSimplification equation then CtxSimplification else CtxFunction
458+ in [ equationKind `withId` ruleIdText equation
459+ , CLNullary CtxSuccess
460+ , CtxTerm `withShortId` showHashHex (hash result)
461+ , CLNullary CtxKoreTerm
462+ ]
463+
464+ oneLineJson (DebugApplyEquation _ result) =
465+ JSON. toJSON $ Kore.Syntax.Json. fromTermLike . getRewritingTerm $ toTermLike result
489466
490467{- | Log when an 'Equation' is actually applied.
491468
0 commit comments