Skip to content

Commit

Permalink
Avoid double parentheses
Browse files Browse the repository at this point in the history
  • Loading branch information
jespercockx committed Jul 2, 2024
1 parent 5f09f42 commit f5ac455
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Agda2Hs/HsUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f5ac455

Please sign in to comment.