@@ -22,6 +22,7 @@ import Idris.Core.Evaluate
2222
2323import Data.Maybe
2424import Data.Char
25+import Data.List (isPrefixOf, isSuffixOf)
2526import Control.Monad
2627import Control.Monad.State.Strict
2728
@@ -299,7 +300,9 @@ replaceSplits l ups = updateRHSs 1 (map (rep (expandBraces l)) ups)
299300 else c : updatePat (not (isAlphaNum c)) n tm rest
300301 updatePat start n tm (c:rest) = c : updatePat (not (isAlpha c)) n tm rest
301302
302− addBrackets tm | ' ' `elem` tm = "(" ++ tm ++ ")"
303+ addBrackets tm | ' ' `elem` tm
304+ , not (isPrefixOf "(" tm)
305+ , not (isSuffixOf ")" tm) = "(" ++ tm ++ ")"
303306 | otherwise = tm
304307
305308getUniq nm i