From fc261ea82e185f4caaddd1c9cb25c4ae80bb9c4e Mon Sep 17 00:00:00 2001 From: Ryan Scott Date: Mon, 8 Jul 2024 08:35:59 -0400 Subject: [PATCH 1/2] copilot-prettyprinter: Pretty-print struct update expressions. Refs #526. This commit adds pretty-printing of expressions that update fields of a struct. --- copilot-prettyprinter/src/Copilot/PrettyPrint.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/copilot-prettyprinter/src/Copilot/PrettyPrint.hs b/copilot-prettyprinter/src/Copilot/PrettyPrint.hs index 887346827..a92c61668 100644 --- a/copilot-prettyprinter/src/Copilot/PrettyPrint.hs +++ b/copilot-prettyprinter/src/Copilot/PrettyPrint.hs @@ -100,6 +100,9 @@ ppOp2 op = case op of BwShiftL _ _ -> ppInfix "<<" BwShiftR _ _ -> ppInfix ">>" Index _ -> ppInfix ".!!" + UpdateField (Struct _) _ f -> \ doc1 doc2 -> + parens $ doc1 <+> text "##" <+> text (accessorName f) <+> text "=:" <+> doc2 + UpdateField _ _ _ -> impossible "ppOp2" "Copilot.PrettyPrint" -- | Pretty-print a ternary operation. ppOp3 :: Op3 a b c d -> Doc -> Doc -> Doc -> Doc From cc9ca2276e86676ef41393412224cff96c952a61 Mon Sep 17 00:00:00 2001 From: Ryan Scott Date: Wed, 21 Aug 2024 12:03:35 -0400 Subject: [PATCH 2/2] copilot-prettyprinter: Document changes in CHANGELOG. Refs #526. --- copilot-prettyprinter/CHANGELOG | 3 +++ 1 file changed, 3 insertions(+) diff --git a/copilot-prettyprinter/CHANGELOG b/copilot-prettyprinter/CHANGELOG index 8bc83df62..d91bb375e 100644 --- a/copilot-prettyprinter/CHANGELOG +++ b/copilot-prettyprinter/CHANGELOG @@ -1,3 +1,6 @@ +2024-08-30 + * Add support for pretty-printing struct update expressions. (#526) + 2024-07-07 * Version bump (3.20). (#522)