From 6dcff8b1518f8f6fa42095065398b879254fae09 Mon Sep 17 00:00:00 2001 From: Leni Aniva Date: Wed, 5 Jun 2024 15:56:20 -0700 Subject: [PATCH] fix: Print diag in mvar context --- Pantograph/Protocol.lean | 1 + Pantograph/Serial.lean | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Pantograph/Protocol.lean b/Pantograph/Protocol.lean index f73c3b0..271d4b7 100644 --- a/Pantograph/Protocol.lean +++ b/Pantograph/Protocol.lean @@ -273,6 +273,7 @@ structure GoalDiag where -- Print all mvars printAll: Bool := false instantiate: Bool := true + printSexp: Bool := false abbrev CR α := Except InteractionError α diff --git a/Pantograph/Serial.lean b/Pantograph/Serial.lean index e12bb7a..8f56468 100644 --- a/Pantograph/Serial.lean +++ b/Pantograph/Serial.lean @@ -311,7 +311,7 @@ protected def GoalState.diag (goalState: GoalState) (options: Protocol.GoalDiag ) pure $ result ++ (resultGoals.map (· ++ "\n") |> String.join) ++ (resultOthers.map (· ++ "\n") |> String.join) where - printMVar (pref: String) (mvarId: MVarId) (decl: MetavarDecl): MetaM String := do + printMVar (pref: String) (mvarId: MVarId) (decl: MetavarDecl): MetaM String := mvarId.withContext do let resultFVars: List String ← if options.printContext then decl.lctx.fvarIdToDecl.toList.mapM (λ (fvarId, decl) => @@ -321,8 +321,12 @@ protected def GoalState.diag (goalState: GoalState) (options: Protocol.GoalDiag let type ← if options.instantiate then instantiateAll decl.type else pure $ decl.type - let type_sexp ← serializeExpressionSexp type (sanitize := false) - let resultMain: String := s!"{pref}{mvarId.name}{userNameToString decl.userName}: {← Meta.ppExpr decl.type} {type_sexp}" + let type_sexp ← if options.printSexp then + let sexp ← serializeExpressionSexp type (sanitize := false) + pure <| " " ++ sexp + else + pure "" + let resultMain: String := s!"{pref}{mvarId.name}{userNameToString decl.userName}: {← Meta.ppExpr decl.type}{type_sexp}" let resultValue: String ← if options.printValue then if let Option.some value := (← getMCtx).eAssignment.find? mvarId then