From f5ac455b0d6e4364f4195918fe1cf215a3e8c434 Mon Sep 17 00:00:00 2001 From: Jesper Cockx Date: Fri, 28 Jun 2024 15:18:26 +0200 Subject: [PATCH] Avoid double parentheses --- src/Agda2Hs/HsUtils.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Agda2Hs/HsUtils.hs b/src/Agda2Hs/HsUtils.hs index ab6d293b..e7665486 100644 --- a/src/Agda2Hs/HsUtils.hs +++ b/src/Agda2Hs/HsUtils.hs @@ -256,14 +256,18 @@ insertPars fixs = \case parL topOp e = if needParenExpr e - then Paren () e + then mkParen e else par topOp (needParen (AssocLeft () /=)) e parR topOp = par topOp (needParen (AssocRight () /=)) par topOp need e@(InfixApp _ _ op _) - | need (getFix topOp) (getFix op) = Paren () e + | need (getFix topOp) (getFix op) = mkParen e par _ _ e = e +mkParen :: Exp () -> Exp () +mkParen e@Paren{} = e +mkParen e = Paren () e + -- Patterns patToExp :: Pat l -> Maybe (Exp l)