Skip to content

Commit

Permalink
make ppEqCWithProv usable by the Pretty instance
Browse files Browse the repository at this point in the history
When debugging larger datatypes that contain deep instances of `EqC`s,
it's much more convenient to be able to change the `Pretty`.
  • Loading branch information
Ptival committed Sep 29, 2023
1 parent b21b80b commit b3af2a2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Reopt/TypeInference/Solver/Constraints.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@ prettySExp docs = PP.group $ PP.encloseSep "(" ")" " " docs
-- output relatively compact. Use 'ppEqCWithProv' if you want to include
-- 'eqProv'.
instance PP.Pretty EqC where
pretty (EqC l r _prov) = prettySExp [PP.pretty l, "=", PP.pretty r]
pretty = ppEqCWithoutProv
-- pretty = ppEqCWithProv

-- | Pretty-print an 'EqC', including its provenance.
ppEqCWithoutProv :: EqC -> PP.Doc ann
ppEqCWithoutProv (EqC l r _) = prettySExp [PP.pretty l, "=", PP.pretty r]

ppEqCWithProv :: EqC -> PP.Doc ann
ppEqCWithProv eqC =
PP.align $
PP.vsep
[ PP.pretty eqC
[ ppEqCWithoutProv eqC
, PP.hang 2 $ "Provenance: " <> PP.pretty (eqProv eqC)
]

Expand Down

0 comments on commit b3af2a2

Please sign in to comment.