This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prnInfix :: Expr -> String | |
prnInfix = para infixAlg where | |
infixAlg (Op Add xs) = concat (intersperse " + " (map fst xs)) | |
infixAlg (Op Mul xs) = concat (intersperse " * " (map parensPlus xs)) | |
infixAlg (Cst n) = show n | |
infixAlg (Var v) = v | |
parensPlus (s, Fix (Op Add _)) = "(" ++ s ++ ")" | |
parensPlus (s, _) = s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment