From 00d92d3f251d45e9b23ea38e4a992ab655c1db58 Mon Sep 17 00:00:00 2001 From: rhiannon morris Date: Sat, 12 Aug 2023 10:24:59 +0200 Subject: [PATCH] add missing parens in pretty printer --- lib/Quox/Syntax/Term/Pretty.idr | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/Quox/Syntax/Term/Pretty.idr b/lib/Quox/Syntax/Term/Pretty.idr index e7addb1..3b91f49 100644 --- a/lib/Quox/Syntax/Term/Pretty.idr +++ b/lib/Quox/Syntax/Term/Pretty.idr @@ -426,17 +426,19 @@ prettyTerm dnames tnames (Enum cases _) = prettyTerm dnames tnames (Tag tag _) = prettyTag tag -prettyTerm dnames tnames (Eq (S _ (N ty)) l r _) = do - l <- withPrec InEq $ prettyTerm dnames tnames l - r <- withPrec InEq $ prettyTerm dnames tnames r - ty <- withPrec InEq $ prettyTerm dnames tnames ty - pure $ sep [l <++> !eqndD, r <++> !colonD, ty] +prettyTerm dnames tnames (Eq (S _ (N ty)) l r _) = + parensIfM Eq =<< do + l <- withPrec InEq $ prettyTerm dnames tnames l + r <- withPrec InEq $ prettyTerm dnames tnames r + ty <- withPrec InEq $ prettyTerm dnames tnames ty + pure $ sep [l <++> !eqndD, r <++> !colonD, ty] -prettyTerm dnames tnames (Eq ty l r _) = do - ty <- prettyTypeLine dnames tnames ty - l <- withPrec Arg $ prettyTerm dnames tnames l - r <- withPrec Arg $ prettyTerm dnames tnames r - prettyAppD !eqD [ty, l, r] +prettyTerm dnames tnames (Eq ty l r _) = + parensIfM Arg =<< do + ty <- prettyTypeLine dnames tnames ty + l <- withPrec Arg $ prettyTerm dnames tnames l + r <- withPrec Arg $ prettyTerm dnames tnames r + prettyAppD !eqD [ty, l, r] prettyTerm dnames tnames s@(DLam {}) = prettyLambda dnames tnames s