Closed heades closed 8 years ago
Checkout the following for how to do this:
https://github.com/heades/gradual-typing/blob/master/impl/Pretty.hs
Work in progress.
I addressed proper parens for Lolly (if first arg is another Lolly, parenthesize), App (if first arg is another App, parenthesize), adjusted Lam (from bound var to . parenthesize).
You said:
App (if first arg is another App, parenthesize)
This is not needed, because (t1 t2) t3 = t1 t2 t3, because application is left associative.
If the first argument to an application is not an application or unit, then it needs to be parenthesized.
The output to the pretty printer will not be correct for some inputs due to parenthesization.
For example, prettyType applied to "Lolly (Lolly I I) I" will out put "I -o I -o I", which is actually, "I -o (I -o I)", but the correct output should be "(I -o I) -o I" which is semantically different.
So proper parens to be accounted for.