Skip to content

Commit

Permalink
copilot-prettyprinter: Pretty-print struct update expressions. Refs C…
Browse files Browse the repository at this point in the history
…opilot-Language#526.

This commit adds pretty-printing of expressions that update fields of a struct.
  • Loading branch information
RyanGlScott committed Aug 21, 2024
1 parent 6034e6d commit 905cfe5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions copilot-prettyprinter/src/Copilot/PrettyPrint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ ppOp2 op = case op of
BwShiftL _ _ -> ppInfix "<<"
BwShiftR _ _ -> ppInfix ">>"
Index _ -> ppInfix ".!!"
UpdateField (Struct _) _ f -> \ doc1 doc2 ->
text "(UpdateStruct" <+> doc1 <+>
text "at" <+> text (accessorName f) <+>
text "to" <+> doc2 <> text ")"
UpdateField _ _ _ -> impossible "ppOp2" "Copilot.PrettyPrint"

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

0 comments on commit 905cfe5

Please # to comment.