Better display of boolean formulas
I want to implement a method for showing a propositional formula in SML. The solutions that I found so far was of this type: fun show (Atom a) = a | show (Neg p) = "(~ " ^ show p ^ ")" | show (Conj(p,q)) = "(" ^ show p ^ " & " ^ show q ^ ")" | show (Disj(p,q)) = "(" ^ show p ^ " | " ^ show q ^ ")"; This produces unnecessary braces: ((~p) & (q | r)) when, what I'd like to have is: ~ p & (q | r) I saw, that Haskell has a function (display?) which does this nicely. Can someone help me out a little bit. How should I go about this? If you want to eliminate redundant parentheses, you will need to