Skip to content

Commit fc261ea

Browse files
committed
copilot-prettyprinter: Pretty-print struct update expressions. Refs #526.
This commit adds pretty-printing of expressions that update fields of a struct.
1 parent 0f5055e commit fc261ea

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

copilot-prettyprinter/src/Copilot/PrettyPrint.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ ppOp2 op = case op of
100100
BwShiftL _ _ -> ppInfix "<<"
101101
BwShiftR _ _ -> ppInfix ">>"
102102
Index _ -> ppInfix ".!!"
103+
UpdateField (Struct _) _ f -> \ doc1 doc2 ->
104+
parens $ doc1 <+> text "##" <+> text (accessorName f) <+> text "=:" <+> doc2
105+
UpdateField _ _ _ -> impossible "ppOp2" "Copilot.PrettyPrint"
103106

104107
-- | Pretty-print a ternary operation.
105108
ppOp3 :: Op3 a b c d -> Doc -> Doc -> Doc -> Doc

0 commit comments

Comments
 (0)