Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Agda2Hs/Language/Haskell/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ uses ty = not . null . usedTypesOf ty

-- Ideally, our pretty-printing library should insert parenthesis where needed.
-- However, hs-src-exts does not insert adequate parenthesis for infix
-- operators so we need to insert some by hand (see issues #54 and #273 and #317).
-- operators so we need to insert some by hand
-- (see issues #54 and #273 and #317 and #460).

-- | Properly parenthesize an expression with regards to the default fixities.
insertParens :: Data a => a -> a
Expand Down Expand Up @@ -254,6 +255,7 @@ insertPars fixs = \case

needParenExpr (InfixApp _ _ _ e2) = needParenExpr e2
needParenExpr Lambda{} = True
needParenExpr If{} = True
needParenExpr _ = False

parL topOp e =
Expand Down
6 changes: 6 additions & 0 deletions test/Succeed/Issue460.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
open import Haskell.Prelude

prepend : Bool → List Int → List Int
prepend b xs = (if b then 1 ∷ [] else []) ++ xs

{-# COMPILE AGDA2HS prepend #-}
5 changes: 5 additions & 0 deletions test/Succeed/Issue460.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Issue460 where

prepend :: Bool -> [Int] -> [Int]
prepend b xs = (if b then [1] else []) ++ xs

Loading