The spirit of declarative programming lies in the fact that you try to just tell the compiler what something means. Instead of thinking about keeping track of the numbers of parentheses, and then applying them afterwards, I would suggest you create a function to do the same job:
bracketed :: String -> String
bracketed s = "(" ++ s ++ ")"
This would allow you to remove the numeric argument, and also write cleaner code.
The second thing that you can improve is the pattern matching. You can use
isPrefixOf to check functions, or use a take inside a case statement to get cleaner handling of different cases.
case take 3 str of
"sin" -> ...
"cos" -> ...
_ -> ...
This would also let you debug your code more easily, just as you require.