diff --git a/src/Agda2Hs/Language/Haskell/Utils.hs b/src/Agda2Hs/Language/Haskell/Utils.hs index c692e4a7..29e8ec3a 100644 --- a/src/Agda2Hs/Language/Haskell/Utils.hs +++ b/src/Agda2Hs/Language/Haskell/Utils.hs @@ -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 @@ -254,6 +255,7 @@ insertPars fixs = \case needParenExpr (InfixApp _ _ _ e2) = needParenExpr e2 needParenExpr Lambda{} = True + needParenExpr If{} = True needParenExpr _ = False parL topOp e = diff --git a/test/Succeed/Issue460.agda b/test/Succeed/Issue460.agda new file mode 100644 index 00000000..09fd927a --- /dev/null +++ b/test/Succeed/Issue460.agda @@ -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 #-} diff --git a/test/Succeed/Issue460.hs b/test/Succeed/Issue460.hs new file mode 100644 index 00000000..ffd04efb --- /dev/null +++ b/test/Succeed/Issue460.hs @@ -0,0 +1,5 @@ +module Issue460 where + +prepend :: Bool -> [Int] -> [Int] +prepend b xs = (if b then [1] else []) ++ xs +