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 8d3f97c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Reopt/TypeInference/Solver/Constraints.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,19 @@ 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', omitting its provenance.
ppEqCWithoutProv :: EqC -> PP.Doc ann
ppEqCWithoutProv (EqC l r _) = prettySExp [PP.pretty l, "=", PP.pretty r]

-- | Pretty-print an 'EqC', including its provenance.
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 8d3f97c

Please sign in to comment.